Skip to content

Commit 7ad786d

Browse files
author
hirsch88
committed
House cleaning
1 parent 9d7be1c commit 7ad786d

File tree

20 files changed

+157
-32
lines changed

20 files changed

+157
-32
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
6363
* [aurelia-typescript-boilerplate](https://github.com/w3tecch/aurelia-typescript-boilerplate) - An Aurelia starter kit with TypeScript
6464

6565
## Documentations
66-
* [Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
66+
* [Express](https://expressjs.com/)
67+
* [Knex](http://knexjs.org/)
68+
* [Bookshelf](http://bookshelfjs.org/)
6769
* [Bookshelf Cheatsheet](http://ricostacruz.com/cheatsheets/bookshelf.html)
70+
* [Inversify](http://inversify.io/)
71+
* [Inversify Express Utils](https://github.com/inversify/inversify-express-utils)
72+
* [Auth0 API Documentation](https://auth0.com/docs/api/management/v2#!/Users/get_users)
6873

6974
## License
7075
[MIT](/LICENSE)

src/api/controllers/HomeController.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ import * as express from 'express';
22
import { Controller, Get, Response } from 'inversify-express-utils';
33
import { injectable } from 'inversify';
44

5+
/**
6+
* HomeController is a public controller to give some
7+
* information about this api
8+
*
9+
* @export
10+
* @class HomeController
11+
*/
512
@injectable()
613
@Controller('/')
714
export class HomeController {
815

916
@Get('/')
10-
public get(@Response() res: express.Response): any {
17+
public get( @Response() res: express.Response): any {
1118
const pkg = require('../../../package.json');
1219
return res.json({
1320
name: pkg.name,

src/api/controllers/UserController.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { injectable, inject } from 'inversify';
22
import { Controller, Get, Post, Put, Delete, RequestParam, RequestBody, Response } from 'inversify-express-utils';
33
import { my } from 'my-express';
44
import { Log } from '../../core/log';
5-
import { UserService } from '../services';
5+
import { UserService } from '../services/UsersService';
66
import { Types } from '../../constants/Types';
77

88
const log = new Log('api:ctrl.UserController');
99

1010
/**
11-
* UserController
11+
* UserController is in charge of the user resource and should
12+
* provide all crud actions.
1213
*
1314
* @export
1415
* @class UserController

src/api/controllers/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/api/exceptions/DatabaseException.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { Exception } from '../../core/api/Exception';
22

3-
3+
/**
4+
* DatabaseException should be used for repository errors like
5+
* entity with this id already exists and stuff like that.
6+
*
7+
* @export
8+
* @class DatabaseException
9+
* @extends {Exception}
10+
*/
411
export class DatabaseException extends Exception {
512
constructor(text: string, error: any) {
613
let value: string = error.stack.split('\n')[0];

src/api/exceptions/NotFoundException.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { Exception } from '../../core/api/Exception';
22

3-
3+
/**
4+
* NotFoundException should be used if a someone requests a
5+
* entity with a id, but there is no entity with this id in the
6+
* database, then we throw this exception.
7+
*
8+
* @export
9+
* @class NotFoundException
10+
* @extends {Exception}
11+
*/
412
export class NotFoundException extends Exception {
513
constructor(id?: number | string) {
614
super(404, `Entity with identifier ${id} does not exist`);

src/api/exceptions/ValidationException.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { Exception } from '../../core/api/Exception';
22

3-
3+
/**
4+
* ValidationException should be used when we validate
5+
* the request payload, so we can response with a 400 (Bad Request)
6+
*
7+
* @export
8+
* @class ValidationException
9+
* @extends {Exception}
10+
*/
411
export class ValidationException extends Exception {
512
constructor(text: string, errors: any) {
613
const info = errors.map((e) => ({

src/api/exceptions/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/api/models/User.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { Bookshelf } from '../../core/Bookshelf';
22
import { Tables } from '../../constants/Tables';
33

4-
4+
/**
5+
* User Model
6+
*
7+
* @export
8+
* @class User
9+
* @extends {Bookshelf.Model<User>}
10+
*/
511
export class User extends Bookshelf.Model<User> {
612

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

0 commit comments

Comments
 (0)