Skip to content

Commit a1956d2

Browse files
committed
Solve Types problems
1 parent 1805d2c commit a1956d2

File tree

9 files changed

+25
-27
lines changed

9 files changed

+25
-27
lines changed

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/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

0 commit comments

Comments
 (0)