Skip to content

Commit 9074e29

Browse files
author
Gery Hirschfeld
authored
Merge pull request #28 from gualtierim/develop
Develop
2 parents 0f2df37 + 2690af0 commit 9074e29

File tree

17 files changed

+42
-43
lines changed

17 files changed

+42
-43
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
APP_NAME="express-typescript-boilerplate"
55
APP_ENV="local"
6-
APP_HOST="http://localhost:3000"
6+
APP_HOST="http://localhost"
77
APP_URL_PREFIX="/api"
88
APP_PORT=3000
99

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- "7.7.3"
3+
- "8.2.1"
44
install:
55
- yarn install
66
scripts:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
environment:
2-
nodejs_version: "7"
2+
nodejs_version: "8"
33

44
install:
55
- ps: Install-Product node $env:nodejs_version

package-scripts.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ module.exports = {
5353
)
5454
},
5555
pretest: {
56-
script: './node_modules/.bin/tslint -c ./tslint.json -t stylish "./test/unit/**/*.ts"'
56+
script: '\"./node_modules/.bin/tslint\" -c ./tslint.json -t stylish "./test/unit/**/*.ts"'
5757
},
5858
run: {
59-
script: './node_modules/.bin/cross-env NODE_ENV=test \"./node_modules/.bin/jest\" --testPathPattern=unit'
59+
script: '\"./node_modules/.bin/cross-env\" NODE_ENV=test \"./node_modules/.bin/jest\" --testPathPattern=unit'
6060
},
6161
verbose: {
6262
script: 'nps "test --verbose"'
@@ -75,28 +75,28 @@ module.exports = {
7575
)
7676
},
7777
pretest: {
78-
script: './node_modules/.bin/tslint -c ./tslint.json -t stylish "./test/e2e/**/*.ts"'
78+
script: '\"./node_modules/.bin/tslint\" -c ./tslint.json -t stylish "./test/e2e/**/*.ts"'
7979
},
8080
verbose: {
8181
script: 'nps "test.e2e --verbose"'
8282
},
8383
run: series(
8484
`wait-on --timeout 120000 http-get://localhost:3000/api/info`,
85-
'./node_modules/.bin/cross-env NODE_ENV=test \"./node_modules/.bin/jest\" --testPathPattern=e2e -i'
85+
'\"./node_modules/.bin/cross-env\" NODE_ENV=test \"./node_modules/.bin/jest\" --testPathPattern=e2e -i'
8686
),
8787
}
8888
},
8989
/**
9090
* Runs TSLint over your project
9191
*/
9292
lint: {
93-
script: `./node_modules/.bin/tslint -c ./tslint.json -p tsconfig.json 'src/**/*.ts' --format stylish`
93+
script: `"./node_modules/.bin/tslint" -c ./tslint.json -p tsconfig.json 'src/**/*.ts' --format stylish`
9494
},
9595
/**
9696
* Transpile your app into javascript
9797
*/
9898
transpile: {
99-
script: `./node_modules/.bin/tsc`
99+
script: `"./node_modules/.bin/tsc"`
100100
},
101101
/**
102102
* Clean files and folders
@@ -106,7 +106,7 @@ module.exports = {
106106
script: series(`nps banner.clean`, `nps clean.dist`)
107107
},
108108
dist: {
109-
script: `./node_modules/.bin/trash './dist'`
109+
script: `"./node_modules/.bin/trash" './dist'`
110110
}
111111
},
112112
/**
@@ -178,11 +178,11 @@ function banner(name) {
178178
}
179179

180180
function copy(source, target) {
181-
return `./node_modules/.bin/copyup ${source} ${target}`
181+
return `"./node_modules/.bin/copyup" ${source} ${target}`
182182
}
183183

184184
function run(path) {
185-
return `./node_modules/.bin/ts-node ${path}`
185+
return `"./node_modules/.bin/ts-node" ${path}`
186186
}
187187

188188
function runFast(path) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A delightful way to building a RESTful API with NodeJs & TypeScript",
55
"main": "src/app.ts",
66
"engines": {
7-
"node": "8.2.1"
7+
"node": ">= 6.9.1"
88
},
99
"scripts": {
1010
"start": "node dist/app.js",
@@ -85,7 +85,7 @@
8585
"helmet": "^3.9.0",
8686
"inquirer": "^3.3.0",
8787
"inversify": "^4.5.0",
88-
"inversify-express-utils": "^4.1.0",
88+
"inversify-express-utils": "^4.2.2",
8989
"jsonwebtoken": "^8.1.0",
9090
"knex": "^0.13.0",
9191
"lodash": "^4.17.4",

src/api/middlewares/AuthenticateMiddleware.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import { inject, named } from 'inversify';
1+
import {inject, named} from 'inversify';
22
import * as Request from 'request';
3-
import { Logger as LoggerType } from '../../core/Logger';
4-
import { Types, Core } from '../../constants';
5-
import { events } from '../../core/api/events';
6-
import { UserAuthenticatedListener } from '../listeners/user/UserAuthenticatedListener';
3+
import {Logger as LoggerType} from '../../core/Logger';
4+
import {Types, Core} from '../../constants';
5+
import {events} from '../../core/api/events';
6+
import {UserAuthenticatedListener} from '../listeners/user/UserAuthenticatedListener';
77

88

99
export class AuthenticateMiddleware implements interfaces.Middleware {
1010

1111
public log: LoggerType;
1212

13-
constructor(
14-
@inject(Types.Core) @named(Core.Logger) Logger: typeof LoggerType,
15-
@inject(Types.Lib) @named('request') private request: typeof Request
16-
) {
13+
constructor(@inject(Types.Core) @named(Core.Logger) Logger: typeof LoggerType,
14+
@inject(Types.Lib) @named('request') private request: typeof Request) {
1715
this.log = new Logger(__filename);
1816
}
1917

@@ -57,7 +55,7 @@ export class AuthenticateMiddleware implements interfaces.Middleware {
5755
}
5856

5957
private getToken(req: myExpress.Request): string | null {
60-
const authorization = req.headers.authorization;
58+
const authorization: string = req.headers.authorization as string;
6159

6260
// Retrieve the token form the Authorization header
6361
if (authorization && authorization.split(' ')[0] === 'Bearer') {

src/config/Database.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export const DatabaseConfig = {
1616
client: process.env.DB_CLIENT,
1717
connection: process.env.DB_CONNECTION,
1818
pool: {
19-
min: parseInt(process.env.DB_POOL_MIN, 10),
20-
max: parseInt(process.env.DB_POOL_MAX, 10)
19+
min: parseInt(process.env.DB_POOL_MIN as string, 10),
20+
max: parseInt(process.env.DB_POOL_MAX as string, 10)
2121
},
2222
migrations: {
2323
directory: process.env.DB_MIGRATION_DIR,

src/config/LoggerConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ import { Configurable } from '../core/App';
1313
export class LoggerConfig implements Configurable {
1414
public configure(): void {
1515
Logger.addAdapter('winston', WinstonAdapter);
16-
Logger.setAdapter(process.env.LOG_ADAPTER);
16+
Logger.setAdapter(process.env.LOG_ADAPTER as string);
1717
}
1818
}

src/console/templates/seed.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'reflect-metadata';
12
import * as Knex from 'knex';
23

34
import { Factory } from '../factories';

src/core/ApiInfo.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { ApiMonitor } from './ApiMonitor';
77
export class ApiInfo {
88

99
public static getRoute(): string {
10-
return process.env.APP_URL_PREFIX + process.env.API_INFO_ROUTE;
10+
return process.env.APP_URL_PREFIX as string + process.env.API_INFO_ROUTE;
1111
}
1212

1313
public setup(application: express.Application): void {
14-
if (Environment.isTruthy(process.env.API_INFO_ENABLED)) {
14+
if (Environment.isTruthy(process.env.API_INFO_ENABLED as string)) {
1515
application.get(
1616
ApiInfo.getRoute(),
1717
// @ts-ignore: False type definitions from express
@@ -20,11 +20,11 @@ export class ApiInfo {
2020
const links = {
2121
links: {}
2222
};
23-
if (Environment.isTruthy(process.env.SWAGGER_ENABLED)) {
23+
if (Environment.isTruthy(process.env.SWAGGER_ENABLED as string)) {
2424
links.links['swagger'] =
2525
`${application.get('host')}${SwaggerUI.getRoute()}`;
2626
}
27-
if (Environment.isTruthy(process.env.MONITOR_ENABLED)) {
27+
if (Environment.isTruthy(process.env.MONITOR_ENABLED as string)) {
2828
links.links['monitor'] =
2929
`${application.get('host')}${ApiMonitor.getRoute()}`;
3030
}

src/core/ApiMonitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { BasicAuthentication } from './BasicAuthentication';
77
export class ApiMonitor {
88

99
public static getRoute(): string {
10-
return process.env.MONITOR_ROUTE;
10+
return process.env.MONITOR_ROUTE as string;
1111
}
1212

1313
public setup(app: express.Application): void {
14-
if (Environment.isTruthy(process.env.MONITOR_ENABLED)) {
14+
if (Environment.isTruthy(process.env.MONITOR_ENABLED as string)) {
1515
app.use(monitor());
1616
app.get(ApiMonitor.getRoute(), BasicAuthentication(), monitor().pageRoute);
1717
}

src/core/BasicAuthentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as basicAuth from 'express-basic-auth';
44
export const BasicAuthentication = (): any => {
55
return basicAuth({
66
users: {
7-
[process.env.APP_BASIC_USER]: process.env.APP_BASIC_PASSWORD
7+
[process.env.APP_BASIC_USER as string]: process.env.APP_BASIC_PASSWORD as string
88
},
99
challenge: true
1010
});

src/core/Bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Bootstrap {
4040

4141
public setupInversifyExpressServer(app: express.Application, ioc: IoC): InversifyExpressServer {
4242
const inversifyExpressServer = new InversifyExpressServer(ioc.container, undefined, {
43-
rootPath: process.env.APP_URL_PREFIX
43+
rootPath: process.env.APP_URL_PREFIX as string
4444
}, app);
4545
// @ts-ignore: False type definitions from express
4646
inversifyExpressServer.setConfig((a) => a.use(extendExpressResponse));

src/core/Server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ export class Server {
7272
this.log.debug(`Environment : ${Environment.getNodeEnv()}`);
7373
this.log.debug(`Version : ${Environment.getPkg().version}`);
7474
this.log.debug(``);
75-
if (Environment.isTruthy(process.env.API_INFO_ENABLED)) {
75+
if (Environment.isTruthy(process.env.API_INFO_ENABLED as string)) {
7676
this.log.debug(`API Info : ${app.get('host')}${ApiInfo.getRoute()}`);
7777
}
78-
if (Environment.isTruthy(process.env.SWAGGER_ENABLED)) {
78+
if (Environment.isTruthy(process.env.SWAGGER_ENABLED as string)) {
7979
this.log.debug(`Swagger : ${app.get('host')}${SwaggerUI.getRoute()}`);
8080
}
81-
if (Environment.isTruthy(process.env.MONITOR_ENABLED)) {
81+
if (Environment.isTruthy(process.env.MONITOR_ENABLED as string)) {
8282
this.log.debug(`Monitor : ${app.get('host')}${ApiMonitor.getRoute()}`);
8383
}
8484
this.log.debug('-------------------------------------------------------');

src/core/SwaggerUI.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import { BasicAuthentication } from './BasicAuthentication';
88
export class SwaggerUI {
99

1010
public static getRoute(): string {
11-
return process.env.SWAGGER_ROUTE;
11+
return process.env.SWAGGER_ROUTE as string;
1212
}
1313

1414
public setup(app: express.Application): void {
15-
if (Environment.isTruthy(process.env.SWAGGER_ENABLED)) {
15+
if (Environment.isTruthy(process.env.SWAGGER_ENABLED as string)) {
1616
const baseFolder = __dirname.indexOf(`${path.sep}src${path.sep}`) >= 0 ? `${path.sep}src${path.sep}` : `${path.sep}dist${path.sep}`;
1717
const basePath = __dirname.substring(0, __dirname.indexOf(baseFolder));
18-
const swaggerFile = require(path.join(basePath, process.env.SWAGGER_FILE));
18+
const swaggerFile = require(path.join(basePath, process.env.SWAGGER_FILE as string));
1919
const packageJson = require(path.join(basePath, 'package.json'));
2020

2121
// Add npm infos to the swagger doc

src/database/seeds/create_users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import 'reflect-metadata';
12
import * as Knex from 'knex';
23

34
import { Factory } from '../factories';
45
import { User } from '../../api/models/User';
56

6-
77
exports.seed = async (db: Knex) => {
88
const factory = Factory.getInstance();
99
await factory.get(User)

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ invariant@^2.2.2:
23092309
dependencies:
23102310
loose-envify "^1.0.0"
23112311

2312-
inversify-express-utils@^4.1.0:
2312+
inversify-express-utils@^4.2.2:
23132313
version "4.2.2"
23142314
resolved "https://registry.yarnpkg.com/inversify-express-utils/-/inversify-express-utils-4.2.2.tgz#dd0a733cfdc7250a09132f7e694afd928ede6583"
23152315
dependencies:

0 commit comments

Comments
 (0)