Skip to content

Commit d9eb59f

Browse files
author
hirsch88
committed
house cleaning
1 parent c71415d commit d9eb59f

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ The route prefix is by default `/api/v1`, but you can change this in the .env.ex
9292
| **src/** | Source-Files |
9393
| **src/api/controllers/** | REST-API - Controllers |
9494
| **src/api/exceptions/** | Exceptions like 404 NotFound |
95+
| **src/api/listeners/** | Event-Listeners |
9596
| **src/api/middlewares/** | Express Middlewares like populateUser |
9697
| **src/api/models/** | Bookshelf Models |
9798
| **src/api/repositories/** | Repository Layer |

src/api/controllers/UserController.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
/**
2+
* UserController
3+
* ----------------------------------------
4+
*
5+
* This controller is in charge of the user resource and should
6+
* provide all crud actions.
7+
*/
8+
19
import { inject, named } from 'inversify';
210
import { Controller, Get, Post, Put, Delete, RequestParam, RequestBody, Response, Request } from 'inversify-express-utils';
311
import { my } from 'my-express';
412
import { UserService } from '../services/UserService';
513
import { Types } from '../../constants/Types';
614
import { Service, Middleware } from '../../constants/Targets';
7-
// import { authenticate, populateUser } from '../middlewares';
815
import { AuthenticateMiddleware } from '../middlewares/AuthenticateMiddleware';
916
import { PopulateUserMiddleware } from '../middlewares/PopulateUserMiddleware';
1017
import { ioc } from '../../core/IoC';
@@ -13,10 +20,7 @@ import { ioc } from '../../core/IoC';
1320
const authenticate = ioc.Container.getNamed<AuthenticateMiddleware>(Types.Middleware, Middleware.AuthenticateMiddleware);
1421
const populateUser = ioc.Container.getNamed<PopulateUserMiddleware>(Types.Middleware, Middleware.PopulateUserMiddleware);
1522

16-
/**
17-
* UserController is in charge of the user resource and should
18-
* provide all crud actions.
19-
*/
23+
2024
@Controller('/user', authenticate.use)
2125
export class UserController {
2226

src/api/models/User.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { Bookshelf } from '../../config/Database';
2-
import { Tables } from '../../constants/Tables';
3-
41
/**
52
* User Model
6-
*
7-
* @export
8-
* @class User
9-
* @extends {Bookshelf.Model<User>}
3+
* ------------------------------
104
*/
5+
6+
import { Bookshelf } from '../../config/Database';
7+
import { Tables } from '../../constants/Tables';
8+
9+
1110
export class User extends Bookshelf.Model<User> {
1211

1312
public static async fetchById(id: number): Promise<User> {

src/api/repositories/UserRepository.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* UserRepository
3+
* ------------------------------
4+
*/
5+
16
import * as Bookshelf from 'bookshelf';
27
import { inject, named } from 'inversify';
38
import { Types } from '../../constants/Types';
@@ -6,12 +11,7 @@ import { User } from '../models/User';
611
import { DatabaseException } from '../exceptions/DatabaseException';
712
import { NotFoundException } from '../exceptions/NotFoundException';
813

9-
/**
10-
* UserRepository
11-
*
12-
* @export
13-
* @class UserRepository
14-
*/
14+
1515
export class UserRepository {
1616

1717
constructor(

src/api/services/UserService.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* UserService
3+
* ------------------------------
4+
*
5+
* This service is here to validate and call the repository layer for
6+
* database actions. Furthermore you should throw events here if
7+
* necessary.
8+
*
9+
*/
10+
111
import * as Bookshelf from 'bookshelf';
212
import { inject, named } from 'inversify';
313
import { Core, Repository } from '../../constants/Targets';
@@ -13,16 +23,6 @@ import { User } from '../models/User';
1323
import { UserCreatedListener } from '../listeners/UserCreatedListener';
1424

1525

16-
/**
17-
* UserService
18-
* ------------------------------
19-
* This service is here to validate and call the repository layer for
20-
* database actions. Furthermore you should throw events here if
21-
* necessary.
22-
*
23-
* @export
24-
* @class UserService
25-
*/
2626
export class UserService {
2727

2828
public log: Log;

0 commit comments

Comments
 (0)