Skip to content

Commit ce7fc08

Browse files
author
hirsch88
committed
Merge branch 'release/1.5.2'
2 parents 37db5bf + 3fa3cf7 commit ce7fc08

File tree

8 files changed

+319
-228
lines changed

8 files changed

+319
-228
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ LOG_ADAPTER=debug
1919
#
2020
SWAGGER_ENABLED=true
2121
SWAGGER_ROUTE=/docs
22-
SWAGGER_FILE='./swagger.json'
22+
SWAGGER_FILE=/src/api/swagger.json
2323

2424
#
2525
# DATABASE

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A delightful way to building a RESTful API with NodeJs & TypeScript.
1111
- **Easy Data Seeding** with our own factories.
1212
- **Custom Commands** are also available in our setup and really easy to use.
1313
- **Smart Validation** thanks to [class-validator](https://github.com/pleerock/class-validator) with some nice annotations.
14-
- **Inline Swagger Documentation** thanks to [swagger-jsdoc](https://github.com/Surnet/swagger-jsdoc)
14+
- **API Documentation** thanks to [swagger](http://swagger.io/).
1515

1616
## Getting Started
1717
### Prerequisites
@@ -83,6 +83,7 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
8383
* [class-validator](https://github.com/pleerock/class-validator)
8484
* [Jest](http://facebook.github.io/jest/)
8585
* [Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
86+
* [swagger Documentation](http://swagger.io/)
8687

8788
## License
8889
[MIT](/LICENSE)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "express-typescript-boilerplate",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"description": "A delightful way to building a RESTful API with NodeJs & TypeScript",
55
"main": "src/index.ts",
66
"scripts": {
@@ -17,7 +17,7 @@
1717
"db:seed": "./node_modules/.bin/knex seed:run",
1818
"db:reset": "npm run console db:reset",
1919
"console": "./node_modules/.bin/ts-node ./src/console/commander.ts",
20-
"serve": "./node_modules/.bin/nodemon --watch 'src/**/*.ts'",
20+
"serve": "./node_modules/.bin/nodemon --watch 'src/**/*.ts' --watch 'src/**/*.json'",
2121
"start": "node src/index.js"
2222
},
2323
"repository": "git+ssh://git@github.com/w3tec/express-typescript-boilerplate.git",

src/api/controllers/HomeController.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ import { injectable } from 'inversify';
1010
@Controller('/v1')
1111
export class HomeController {
1212

13-
/**
14-
* @swagger
15-
* /:
16-
* get:
17-
* tags:
18-
* - Root
19-
* summary: Show API information
20-
* description: Gets the api information
21-
* responses:
22-
* 200:
23-
* description: api information
24-
*/
2513
@Get('/')
2614
public get( @Response() res: express.Response): any {
2715
const pkg = require('../../../package.json');

src/api/controllers/UserController.ts

Lines changed: 0 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -18,216 +18,40 @@ export class UserController {
1818

1919
constructor( @inject(Types.UserService) private userService: UserService) { }
2020

21-
/**
22-
* @swagger
23-
* /user:
24-
* get:
25-
* tags:
26-
* - User
27-
* summary: List all users
28-
* description: Returns users
29-
* security:
30-
* - JWT: []
31-
* responses:
32-
* 200:
33-
* description: List of all users
34-
* schema:
35-
* type: object
36-
* title: UserResponse
37-
* properties:
38-
* success:
39-
* type: boolean
40-
* message:
41-
* type: string
42-
* data:
43-
* type: array
44-
* items:
45-
* $ref: "#/definitions/User"
46-
*/
4721
@Get('/')
4822
public async findAll( @Response() res: my.Response): Promise<any> {
4923
log.debug('findAll');
5024
const users = await this.userService.findAll();
5125
return res.found(users.toJSON());
5226
}
5327

54-
/**
55-
* @swagger
56-
* /user:
57-
* post:
58-
* tags:
59-
* - User
60-
* summary: Create new user
61-
* description: Creates new user and returns him
62-
* security:
63-
* - JWT: []
64-
* parameters:
65-
* - in: "body"
66-
* name: "body"
67-
* required: true
68-
* schema:
69-
* $ref: "#/definitions/NewUser"
70-
* responses:
71-
* 200:
72-
* description: New user
73-
* schema:
74-
* type: object
75-
* title: UserResponse
76-
* properties:
77-
* success:
78-
* type: boolean
79-
* message:
80-
* type: string
81-
* data:
82-
* $ref: "#/definitions/User"
83-
*/
8428
@Post('/')
8529
public async create( @Response() res: my.Response, @RequestBody() body: any): Promise<any> {
8630
log.debug('create ', body);
8731
const user = await this.userService.create(body);
8832
return res.created(user.toJSON());
8933
}
9034

91-
/**
92-
* @swagger
93-
* /user/me:
94-
* get:
95-
* tags:
96-
* - User
97-
* summary: Get logged in user
98-
* description: Returns logged in user
99-
* security:
100-
* - JWT: []
101-
* responses:
102-
* 200:
103-
* description: User
104-
* schema:
105-
* type: object
106-
* title: UserResponse
107-
* properties:
108-
* success:
109-
* type: boolean
110-
* message:
111-
* type: string
112-
* data:
113-
* type: object
114-
* $ref: "#/definitions/User"
115-
*/
11635
@Get('/me', populateUser)
11736
public async findMe( @Request() req: my.Request, @Response() res: my.Response): Promise<any> {
11837
log.debug('findMe');
11938
return res.found(req.user);
12039
}
12140

122-
/**
123-
* @swagger
124-
* /user/{id}:
125-
* get:
126-
* tags:
127-
* - User
128-
* summary: Get user
129-
* description: Returns a user
130-
* security:
131-
* - JWT: []
132-
* responses:
133-
* 200:
134-
* description: User
135-
* schema:
136-
* type: object
137-
* title: UserResponse
138-
* properties:
139-
* success:
140-
* type: boolean
141-
* message:
142-
* type: string
143-
* data:
144-
* type: object
145-
* $ref: "#/definitions/User"
146-
*/
14741
@Get('/:id')
14842
public async findOne( @Response() res: my.Response, @RequestParam('id') id: string): Promise<any> {
14943
log.debug('findOne ', id);
15044
const user = await this.userService.findOne(parseInt(id, 10));
15145
return res.found(user.toJSON());
15246
}
15347

154-
/**
155-
* @swagger
156-
* /user/{id}:
157-
* put:
158-
* tags:
159-
* - User
160-
* summary: Update user
161-
* description: Returns a user
162-
* security:
163-
* - JWT: []
164-
* parameters:
165-
* - name: "id"
166-
* in: "path"
167-
* description: "ID of user to return"
168-
* required: true
169-
* type: "integer"
170-
* format: "int64"
171-
* - in: "body"
172-
* name: "body"
173-
* description: "User object"
174-
* required: true
175-
* schema:
176-
* $ref: "#/definitions/NewUser"
177-
* responses:
178-
* 200:
179-
* description: User
180-
* schema:
181-
* type: object
182-
* title: UserResponse
183-
* properties:
184-
* success:
185-
* type: boolean
186-
* message:
187-
* type: string
188-
* data:
189-
* type: object
190-
* $ref: "#/definitions/User"
191-
*/
19248
@Put('/:id')
19349
public async update( @Response() res: my.Response, @RequestParam('id') id: string, @RequestBody() body: any): Promise<any> {
19450
log.debug('update ', body);
19551
const user = await this.userService.update(parseInt(id, 10), body);
19652
return res.updated(user.toJSON());
19753
}
19854

199-
/**
200-
* @swagger
201-
* /user/{id}:
202-
* delete:
203-
* tags:
204-
* - User
205-
* summary: Delete user
206-
* description: Returns a user
207-
* security:
208-
* - JWT: []
209-
* parameters:
210-
* - name: "id"
211-
* in: "path"
212-
* description: "ID of user to return"
213-
* required: true
214-
* type: "integer"
215-
* format: "int64"
216-
* responses:
217-
* 200:
218-
* description: User
219-
* schema:
220-
* type: object
221-
* title: UserResponse
222-
* properties:
223-
* success:
224-
* type: boolean
225-
* message:
226-
* type: string
227-
* data:
228-
* type: object
229-
* example:
230-
*/
23155
@Delete('/:id')
23256
public async destroy( @Response() res: my.Response, @RequestParam('id') id: string): Promise<any> {
23357
log.debug('destroy ', id);

0 commit comments

Comments
 (0)