Skip to content

Commit f17ddcf

Browse files
author
hirsch88
committed
Merge branch 'release/1.1.0'
2 parents 3fb4ae5 + 92b897b commit f17ddcf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+392
-538
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ coverage/
4141

4242
# Generated documentation #
4343
docs/
44+
old/

.vscode/cSpell.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// cSpell Settings
2+
{
3+
// Version of the setting file. Always 0.1
4+
"version": "0.1",
5+
// language - current active spelling language
6+
"language": "en",
7+
// words - list of words to be always considered correct
8+
"words": [
9+
"hsts"
10+
],
11+
// flagWords - list of words to be always considered incorrect
12+
// This is useful for offensive words and common spelling errors.
13+
// For example "hte" should be "the"
14+
"flagWords": [
15+
"hte"
16+
]
17+
}

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"src/**/*.js": true,
55
"test/**/*.js": true
66
},
7-
"vsicons.presets.angular": false
7+
"vsicons.presets.angular": false,
8+
"cSpell.enabled": true
89
}

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: ./node_modules/.bin/gulp build && npm start

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Express Typescript Boilerplate
22

3-
> Boilerplate for an restful express-apllication written in TypeScript
3+
> Boilerplate for an restful express-application written in TypeScript
44
55
## Getting Started
66
### Prerequisites
@@ -31,7 +31,7 @@ The port will be displayed to you as `http://0.0.0.0:3000` (or if you prefer IPv
3131
* Remove not needed libraries with `npm run install:clean`
3232

3333
### Linting
34-
* Run code analysis using `npm run lint`. This runs tshint.
34+
* Run code analysis using `npm run lint`. This runs tslint.
3535
* There is also a vscode task for this called lint.
3636

3737
### Tests

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "express-typescript-boilerplate",
3-
"version": "1.0.0",
4-
"description": "Boilerplate for an restful express-apllication written in TypeScript.",
3+
"version": "1.1.0",
4+
"description": "Boilerplate for an restful express-application written in TypeScript.",
55
"main": "src/index.ts",
66
"scripts": {
77
"install:typings": "./node_modules/.bin/typings install",
@@ -20,9 +20,9 @@
2020
"db:migrate": "./node_modules/.bin/knex migrate:latest",
2121
"db:migrate:rollback": "./node_modules/.bin/knex migrate:rollback",
2222
"db:seed": "./node_modules/.bin/knex seed:run",
23-
"db:clean": "ts-node ./src/console/CleanDatabaseCommand.ts",
23+
"db:clean": "./node_modules/.bin/ts-node ./src/console/CleanDatabaseCommand.ts",
2424
"db:refresh": "npm run db:drop && npm run db:migrate",
25-
"start": "node ./src/index.js"
25+
"start": "node src/index.js"
2626
},
2727
"repository": "git+ssh://git@github.com/w3tec/express-typescript-boilerplate.git",
2828
"engines": {
@@ -60,6 +60,8 @@
6060
"@types/express": "^4.0.35",
6161
"@types/faker": "^4.1.0",
6262
"@types/helmet": "0.0.34",
63+
"@types/inversify": "^2.0.33",
64+
"@types/inversify-express-utils": "^2.0.0",
6365
"@types/knex": "0.0.47",
6466
"@types/lodash": "^4.14.63",
6567
"@types/morgan": "^1.7.32",
@@ -72,22 +74,22 @@
7274
"bookshelf-camelcase": "^1.1.4",
7375
"compression": "^1.6.2",
7476
"cors": "^2.8.1",
75-
"dataloader": "^1.3.0",
7677
"debug": "^2.6.0",
7778
"express": "^4.14.0",
7879
"faker": "^3.1.0",
7980
"helmet": "^3.4.0",
81+
"inversify": "^4.1.0",
82+
"inversify-express-utils": "^3.5.1",
8083
"knex": "^0.12.7",
8184
"lodash": "^4.17.4",
8285
"morgan": "^1.7.0",
83-
"mysql": "^2.13.0",
86+
"pg": "^6.1.5",
8487
"reflect-metadata": "^0.1.10",
8588
"request": "^2.81.0",
8689
"serve-favicon": "^2.4.2",
8790
"ts-node": "^2.0.0",
88-
"winston": "^2.3.1"
89-
},
90-
"devDependencies": {
91+
"typescript": "^2.3.2",
92+
"winston": "^2.3.1",
9193
"@types/jest": "^19.2.2",
9294
"gulp": "^3.9.1",
9395
"gulp-clean": "^0.3.2",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as express from 'express';
2+
import { Controller, Get, Response } from 'inversify-express-utils';
3+
import { injectable } from 'inversify';
4+
5+
@injectable()
6+
@Controller('/')
7+
export class HomeController {
8+
9+
@Get('/')
10+
public get(@Response() res: express.Response): any {
11+
const pkg = require('../../../package.json');
12+
return res.json({
13+
name: pkg.name,
14+
version: pkg.version,
15+
description: pkg.description
16+
});
17+
}
18+
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { injectable, inject } from 'inversify';
2+
import { Controller, Get, RequestParam } from 'inversify-express-utils';
3+
import TYPES from '../../constants/types';
4+
import * as core from '../../core';
5+
import { UserService } from '../services';
6+
7+
const log = new core.Log('api:ctrl.UserController');
8+
9+
/**
10+
* UserController
11+
*
12+
* @export
13+
* @class UserController
14+
*/
15+
@injectable()
16+
@Controller('/users')
17+
export class UserController {
18+
19+
constructor( @inject(TYPES.UserService) private userService: UserService) { }
20+
21+
@Get('/')
22+
public async findAll(): Promise<any> {
23+
log.debug('findAll');
24+
const users = await this.userService.findAll();
25+
return users.toJSON();
26+
}
27+
28+
@Get('/:id')
29+
public async findOne( @RequestParam('id') id: string): Promise<any> {
30+
log.debug('findOne ', id);
31+
const user = await this.userService.findOne(parseInt(id, 10));
32+
return user.toJSON();
33+
}
34+
35+
}

src/api/controllers/UsersController.ts

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

src/api/controllers/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export * from './UsersController';
1+
export * from './HomeController';
2+
export * from './UserController';

0 commit comments

Comments
 (0)