-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(strict): Make all project files compliant with new strict rules
- Loading branch information
Sander Koenders
committed
Sep 10, 2018
1 parent
d38e97c
commit 3cd2f81
Showing
9 changed files
with
59 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
interface Environment { | ||
appName: string, | ||
port: Number, | ||
loadPaths: Array<string> | ||
} | ||
appName: string; | ||
port: number; | ||
loadPaths: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const TYPES = { | ||
Environment: Symbol("Environment"), | ||
Logger: Symbol("Logger") | ||
Environment: Symbol('Environment'), | ||
Logger: Symbol('Logger') | ||
}; | ||
|
||
export default TYPES; | ||
export default TYPES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import "reflect-metadata"; | ||
import 'reflect-metadata'; | ||
import { Container, inject } from 'inversify'; | ||
import { autoProvide, makeFluentProvideDecorator } from 'inversify-binding-decorators'; | ||
import { autoProvide, provide, fluentProvide } from 'inversify-binding-decorators'; | ||
|
||
let container = new Container(); | ||
const container = new Container(); | ||
|
||
let provide = makeFluentProvideDecorator(container); | ||
|
||
export { container, autoProvide, provide, inject }; | ||
export { container, autoProvide, provide, inject, fluentProvide }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
class Loader { | ||
public static load(baseDir: string) { | ||
Loader.readDir(baseDir); | ||
} | ||
|
||
private static readDir(dir) { | ||
private static readDir(dir: string) { | ||
fs.readdirSync(dir).forEach((entity) => { | ||
Loader.processEntity(path.join(dir, entity)); | ||
}); | ||
} | ||
|
||
private static processEntity(entity: string) { | ||
if(fs.statSync(entity).isDirectory()) { | ||
if (fs.statSync(entity).isDirectory()) { | ||
Loader.readDir(entity); | ||
} | ||
else | ||
{ | ||
} else { | ||
Loader.loadFile(entity); | ||
} | ||
} | ||
|
||
private static loadFile(filePath) { | ||
if(path.extname(filePath) == ".js") { | ||
private static loadFile(filePath: string) { | ||
if (path.extname(filePath) === '.js') { | ||
require(filePath); | ||
} | ||
} | ||
} | ||
|
||
export default Loader; | ||
export default Loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
interface Logger { | ||
log(message: string); | ||
log(message: string): void; | ||
} | ||
|
||
export default Logger; | ||
export default Logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import TYPES from "../../constants/types"; | ||
import Logger from "./logger"; | ||
import { provide, inject } from "../../ioc/ioc"; | ||
import TYPES from '../../constants/types'; | ||
import Logger from './logger'; | ||
import { provide, inject } from '../../ioc/ioc'; | ||
|
||
@provide(TYPES.Logger).done() | ||
/* tslint:disable:no-console */ | ||
@provide(TYPES.Logger) | ||
class LoggerImpl implements Logger { | ||
private _appName: string; | ||
private appName: string; | ||
|
||
public constructor(@inject(TYPES.Environment) environment: any) | ||
{ | ||
this._appName = environment.appName; | ||
public constructor(@inject(TYPES.Environment) environment: any) { | ||
this.appName = environment.appName; | ||
} | ||
|
||
public log(message: string) { | ||
console.log(this._appName + " says: " + message); | ||
console.log(this.appName + ' says: ' + message); | ||
} | ||
} | ||
|
||
export default LoggerImpl; | ||
export default LoggerImpl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import * as express from "express"; | ||
import Loader from "./ioc/loader"; | ||
import * as path from "path"; | ||
import { container } from "./ioc/ioc"; | ||
import TYPES from "./constants/types"; | ||
import * as express from 'express'; | ||
import Loader from './ioc/loader'; | ||
import * as path from 'path'; | ||
import { container } from './ioc/ioc'; | ||
import TYPES from './constants/types'; | ||
|
||
class Main { | ||
private _app: express.Application; | ||
private app: express.Application; | ||
|
||
public constructor(environment: any) { | ||
this._app = express(); | ||
this.app = express(); | ||
|
||
this.initializeDependencyInjector(environment); | ||
} | ||
|
||
public onListening() { | ||
let helloController: any = container.getNamed("Music/HelloController", "testModule"); | ||
const helloController: any = container.getNamed('Music/HelloController', 'testModule'); | ||
|
||
helloController.hello("Sander"); | ||
helloController.hello('Sander'); | ||
} | ||
|
||
private initializeDependencyInjector(environment: any) | ||
{ | ||
private initializeDependencyInjector(environment: any) { | ||
container.bind<Environment>(TYPES.Environment).toConstantValue(environment); | ||
|
||
this.loadJsFiles(environment.loadPaths); | ||
} | ||
|
||
private loadJsFiles(loadPaths: Array<string>) { | ||
private loadJsFiles(loadPaths: string[]) { | ||
loadPaths.forEach((dir) => { | ||
Loader.load(path.join(__dirname, dir)); | ||
}); | ||
} | ||
|
||
public get App(): express.Application { | ||
return this._app; | ||
return this.app; | ||
} | ||
} | ||
|
||
export = Main; | ||
export = Main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { inject, provide } from "../../ioc/ioc"; | ||
import Logger from "../../libraries/logger/logger"; | ||
import TYPES from "../../constants/types"; | ||
import { inject, fluentProvide } from '../../ioc/ioc'; | ||
import Logger from '../../libraries/logger/logger'; | ||
import TYPES from '../../constants/types'; | ||
|
||
@provide("Music/HelloController").whenTargetNamed("awesomeModule").done() | ||
@fluentProvide('Music/HelloController').whenTargetNamed('awesomeModule').done() | ||
class HelloController { | ||
@inject(TYPES.Logger) private _logger: Logger; | ||
@inject(TYPES.Logger) private logger: Logger; | ||
|
||
public hello(name: string) { | ||
this._logger.log("Awesome hello " + name); | ||
this.logger.log('Awesome hello ' + name); | ||
} | ||
} | ||
|
||
export default HelloController; | ||
export default HelloController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { inject, provide } from "../../ioc/ioc"; | ||
import Logger from "../../libraries/logger/logger"; | ||
import TYPES from "../../constants/types"; | ||
import { inject, fluentProvide } from '../../ioc/ioc'; | ||
import Logger from '../../libraries/logger/logger'; | ||
import TYPES from '../../constants/types'; | ||
|
||
@provide("Music/HelloController").whenTargetNamed("testModule").done() | ||
@fluentProvide('Music/HelloController').whenTargetNamed('testModule').done() | ||
class HelloController { | ||
private _logger: Logger; | ||
private logger: Logger; | ||
|
||
public constructor(@inject(TYPES.Logger) logger: Logger) { | ||
this._logger = logger; | ||
this.logger = logger; | ||
} | ||
|
||
public hello(name: string) { | ||
this._logger.log("Hello " + name); | ||
this.logger.log('Hello ' + name); | ||
} | ||
} | ||
|
||
export default HelloController; | ||
export default HelloController; |