Skip to content

Commit

Permalink
Change project layout, add api, add doc (#2)
Browse files Browse the repository at this point in the history
Update template layout, swagger api + doc
  • Loading branch information
hieunmce authored and huygn committed Aug 15, 2018
1 parent 1afca9e commit ad2f972
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 16 deletions.
8 changes: 4 additions & 4 deletions sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ module.exports = {
gitInit: false,
installDependencies: false,
prompts: {
namespace: {
message: 'What is your vsc namespace?',
default: 'dwarvesf',
},
domain: {
message: 'What is your vsc domain?',
default: 'github.com',
},
namespace: {
message: 'What is your vsc namespace?',
default: ':gitUser:',
},
description: {
message: 'How would you describe the new project?',
default: `my ${superb()} Go project`,
Expand Down
55 changes: 55 additions & 0 deletions template/api/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
swagger: "2.0"
info:
description: "<%= description %>"
version: "1.0.0"
title: "<%= _.folderName %> API Document"
host: "localhost:3000"
basePath: "/"
tags:
- name: "add"
description: "add service"
schemes:
- "http"
paths:
/add:
post:
tags:
- "add"
summary: "Add 2 value"
description: "add 2 value and return response"
operationId: "add"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "add 2 value and return response"
required: true
schema:
$ref: "#/definitions/add_post_req"
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/add_post_res"

definitions:
add_post_req:
type: "object"
properties:
add:
type: "object"
properties:
x:
type: "integer"
format: "int32"
y:
type: "integer"
format: "int32"
add_post_res:
properties:
result:
type: "integer"
format: "int32"
12 changes: 6 additions & 6 deletions template/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (

"github.com/go-kit/kit/log"

"<%= domainDir + _.folderName %>/endpoints"
serviceHttp "<%= domainDir + _.folderName %>/http"
"<%= domainDir + _.folderName %>/middlewares"
"<%= domainDir + _.folderName %>/postgres"
"<%= domainDir + _.folderName %>/service"
"<%= domainDir + _.folderName %>/service/add"
"<%= domainDir + _.folderName %>/src/endpoints"
serviceHttp "<%= domainDir + _.folderName %>/src/http"
"<%= domainDir + _.folderName %>/src/middlewares"
"<%= domainDir + _.folderName %>/src/postgres"
"<%= domainDir + _.folderName %>/src/service"
"<%= domainDir + _.folderName %>/src/service/add"
)

func main() {
Expand Down
Empty file added template/doc/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions template/endpoints/add.go → template/src/endpoints/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/go-kit/kit/endpoint"

"<%= domainDir + _.folderName %>/service"
"<%= domainDir + _.folderName %>/service/add"
"<%= domainDir + _.folderName %>/src/service"
"<%= domainDir + _.folderName %>/src/service/add"
)

type AddRequest struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package endpoints
import (
"github.com/go-kit/kit/endpoint"

"<%= domainDir + _.folderName %>/service"
"<%= domainDir + _.folderName %>/src/service"
)

type Endpoints struct {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions template/http/http.go → template/src/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/go-kit/kit/log"
httptransport "github.com/go-kit/kit/transport/http"

"<%= domainDir + _.folderName %>/endpoints"
"<%= domainDir + _.folderName %>/service"
"<%= domainDir + _.folderName %>/src/endpoints"
"<%= domainDir + _.folderName %>/src/service"
)

// NewHTTPHandler ...
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package service

import "<%= domainDir + _.folderName %>/service/add"
import "<%= domainDir + _.folderName %>/src/service/add"

// Service ...
type Service struct {
Expand Down

0 comments on commit ad2f972

Please sign in to comment.