-
-
Notifications
You must be signed in to change notification settings - Fork 292
Closed
Labels
Milestone
Description
Information
- Version: 5.1.0
- Type: Issue/Story
Description
The typeORMService instances is empty on $afterRoutesInit.
Example
@Service()
export class UserService {
private repository: Repository<User>;
constructor(private typeORMService: TypeORMService) {}
$afterRoutesInit() {
// this is throw error , because this.typeORMService.get() return undefined.
//this.repository = this.typeORMService.get().getRepository(User);
}
async find(email: string) {
// Here i see the typeORMService instances . and it work well.
this.repository = this.typeORMService.get().getRepository(User);
return this.repository.findOne(email)
}
}my log:
PS C:\Users\arkadiy\Desktop\Mutual-Fund\web-server> ts-node app
[2019-01-21T08:14:37.335] [DEBUG] [TSED] - Initialize settings
[2019-01-21T08:14:37.342] [INFO ] [TSED] - settings.rootDir => C:\Users\arkadiy\Desktop\Mutual-Fund\web-server
[2019-01-21T08:14:37.342] [INFO ] [TSED] - settings.env => development
[2019-01-21T08:14:37.342] [INFO ] [TSED] - settings.httpPort => 8080
[2019-01-21T08:14:37.343] [INFO ] [TSED] - settings.httpsPort => 8000
[2019-01-21T08:14:37.343] [INFO ] [TSED] - settings.version => 1.0.0
[2019-01-21T08:14:37.343] [INFO ] [TSED] - settings.uploadDir => C:\Users\arkadiy\Desktop\Mutual-Fund\web-server/uploads
[2019-01-21T08:14:37.344] [INFO ] [TSED] - settings.logger => { requestFields: undefined,
debug: true,
logRequest: true,
jsonIndentation: 2 }
[2019-01-21T08:14:37.347] [INFO ] [TSED] - settings.scope => singleton
[2019-01-21T08:14:37.347] [INFO ] [TSED] - settings.errors => { headerName: 'errors' }
[2019-01-21T08:14:37.347] [INFO ] [TSED] - settings.mount => { '/rest':
'C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\web-server/controllers/**/*.ts' }
[2019-01-21T08:14:37.348] [INFO ] [TSED] - settings.exclude => [ '**/*.spec.ts', '**/*.spec.js' ]
[2019-01-21T08:14:37.348] [INFO ] [TSED] - settings.componentsScan => [ 'C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\web-server/middlewares/**/**.{ts,js}',
'C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\web-server/services/**/**.{ts,js}' ]
[2019-01-21T08:14:37.349] [INFO ] [TSED] - settings.acceptMimes => [ 'application/json' ]
[2019-01-21T08:14:37.349] [INFO ] [TSED] - settings.serveStatic => { '/': 'C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\client\\dist' }
[2019-01-21T08:14:37.349] [INFO ] [TSED] - settings.passport => {}
[2019-01-21T08:14:37.349] [INFO ] [TSED] - settings.swagger => [ { doc: 'api-auth',
path: '/api-docs-auth',
outFile:
'C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\swagger\\web-server/swagger-auth.json',
hidden: false } ]
[2019-01-21T08:14:37.350] [INFO ] [TSED] - settings.typeorm => [ { name: 'default',
type: 'mongodb',
host: 'localhost',
port: 27017,
database: 'DBUsers',
logging: true,
entities:
[ 'C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\web-server\\user.model.ts' ] } ]
[2019-01-21T08:14:37.350] [INFO ] [TSED] - Build services
[2019-01-21T08:14:37.351] [DEBUG] [TSED] - InjectorService loaded
[2019-01-21T08:14:37.351] [DEBUG] [TSED] - ServerSettingsService loaded
[2019-01-21T08:14:37.352] [DEBUG] [TSED] - ExpressApplication loaded
[2019-01-21T08:14:37.352] [DEBUG] [TSED] - HttpServer loaded
[2019-01-21T08:14:37.352] [DEBUG] [TSED] - HttpsServer loaded
[2019-01-21T08:14:37.353] [DEBUG] [TSED] - JsonSchemesService built
[2019-01-21T08:14:37.353] [DEBUG] [TSED] - ConverterService built
[2019-01-21T08:14:37.354] [DEBUG] [TSED] - ArrayConverter built
[2019-01-21T08:14:37.354] [DEBUG] [TSED] - DateConverter built
[2019-01-21T08:14:37.354] [DEBUG] [TSED] - MapConverter built
[2019-01-21T08:14:37.354] [DEBUG] [TSED] - PrimitiveConverter built
[2019-01-21T08:14:37.355] [DEBUG] [TSED] - SetConverter built
[2019-01-21T08:14:37.355] [DEBUG] [TSED] - SymbolConverter built
[2019-01-21T08:14:37.355] [DEBUG] [TSED] - ParseService built
[2019-01-21T08:14:37.355] [DEBUG] [TSED] - BodyParamsFilter built
[2019-01-21T08:14:37.356] [DEBUG] [TSED] - CookiesFilter built
[2019-01-21T08:14:37.356] [DEBUG] [TSED] - HeaderParamsFilter built
[2019-01-21T08:14:37.356] [DEBUG] [TSED] - LocalsFilter built
[2019-01-21T08:14:37.356] [DEBUG] [TSED] - PathParamsFilter built
[2019-01-21T08:14:37.357] [DEBUG] [TSED] - QueryParamsFilter built
[2019-01-21T08:14:37.357] [DEBUG] [TSED] - SessionFilter built
[2019-01-21T08:14:37.357] [DEBUG] [TSED] - ValidationService built
[2019-01-21T08:14:37.358] [DEBUG] [TSED] - SendResponseMiddleware built
[2019-01-21T08:14:37.358] [DEBUG] [TSED] - AuthenticatedMiddleware built from class MyAuthenticatedMiddleware
[2019-01-21T08:14:37.358] [DEBUG] [TSED] - AcceptMimesMiddleware built
[2019-01-21T08:14:37.358] [DEBUG] [TSED] - GlobalAcceptMimesMiddleware built
[2019-01-21T08:14:37.359] [DEBUG] [TSED] - GlobalErrorHandlerMiddleware built
[2019-01-21T08:14:37.359] [DEBUG] [TSED] - LogIncomingRequestMiddleware built
[2019-01-21T08:14:37.359] [DEBUG] [TSED] - ResponseViewMiddleware built
[2019-01-21T08:14:37.359] [DEBUG] [TSED] - RouteService built
[2019-01-21T08:14:37.363] [DEBUG] [TSED] - ControllerService built
[2019-01-21T08:14:37.363] [DEBUG] [TSED] - ServeStaticService built
[2019-01-21T08:14:37.364] [DEBUG] [TSED] - SwaggerService built
[2019-01-21T08:14:37.364] [DEBUG] [TSED] - SwaggerModule built
[2019-01-21T08:14:37.364] [DEBUG] [TSED] - TypeORMService built
[2019-01-21T08:14:37.365] [DEBUG] [TSED] - TypeORMModule built
[2019-01-21T08:14:37.365] [DEBUG] [TSED] - UserService built
[2019-01-21T08:14:37.365] [DEBUG] [TSED] - PassportCtrl built
[2019-01-21T08:14:37.366] [DEBUG] [TSED] - FundCtrl built
[2019-01-21T08:14:37.366] [DEBUG] [TSED] - PassportLocalService built
[2019-01-21T08:14:37.366] [DEBUG] [TSED] - Call hook $onInit
[2019-01-21T08:14:37.367] [INFO ] [TSED] - Create connection with typeorm to database: default
[2019-01-21T08:14:37.367] [DEBUG] [TSED] - options: {"name":"default","type":"mongodb","host":"localhost","port":27017,"database":"DBUsers","logging":true,"entities":["C:\\Users\\arkadiy\\Desktop\\Mutual-Fund\\web-server\\user.model.ts"]}
All services is ready
[2019-01-21T08:14:37.573] [DEBUG] [TSED] - Call hook $onInit promises built
(node:13864) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option {
useNewUrlParser: true } to MongoClient.connect.
[2019-01-21T08:14:38.572] [DEBUG] [TSED] - Settings and injector loaded
[2019-01-21T08:14:38.573] [DEBUG] [TSED] - Mount middlewares
[2019-01-21T08:14:38.574] [DEBUG] [TSED] - Call hook $onMountingMiddlewares
[2019-01-21T08:14:38.618] [DEBUG] [TSED] - Call hook $beforeRoutesInit
Controllers and routes isn't mounted
[2019-01-21T08:14:38.619] [DEBUG] [TSED] - Call hook $onRoutesInit
[2019-01-21T08:14:38.619] [INFO ] [TSED] - Map controllers
Controllers and routes are being built
[2019-01-21T08:14:38.620] [DEBUG] [TSED] - Call hook $afterRoutesInit
[2019-01-21T08:14:38.620] [INFO ] [TSED] - Routes mounted :
[2019-01-21T08:14:38.621] [INFO ] [TSED] -
┌────────────────┬────────────────────────────┬────────────────────────────────┐
│ Method │ Endpoint │ Class method │
│────────────────│────────────────────────────│────────────────────────────────│
│ POST │ /rest/auth/login │ PassportCtrl.login() │
│────────────────│────────────────────────────│────────────────────────────────│
│ POST │ /rest/auth/isAuthenticated │ PassportCtrl.isAuthenticated() │
│────────────────│────────────────────────────│────────────────────────────────│
│ GET │ /rest/auth/logout │ PassportCtrl.logout() │
│────────────────│────────────────────────────│────────────────────────────────│
│ GET │ /rest/funds │ FundCtrl.get() │
│────────────────│────────────────────────────│────────────────────────────────│
│ POST │ /rest/funds/save │ FundCtrl.post() │
└────────────────┴────────────────────────────┴────────────────────────────────┘
Controllers and routes are built
typeORMService:
undefined
[2019-01-21T08:14:38.630] [DEBUG] [TSED] - Start server on http://0.0.0.0:8080
[2019-01-21T08:14:38.630] [DEBUG] [TSED] - Start server on https://0.0.0.0:8000
[2019-01-21T08:14:38.633] [INFO ] [TSED] - HTTP Server listen on http://0.0.0.0:8080
[2019-01-21T08:14:38.634] [INFO ] [TSED] - HTTP Server listen on https://0.0.0.0:8000
[2019-01-21T08:14:38.634] [DEBUG] [TSED] - Call hook $onReady
Server started...
[2019-01-21T08:14:38.635] [DEBUG] [TSED] - Call hook $onServerReady
[2019-01-21T08:14:38.635] [INFO ] [TSED] - [api-auth] Swagger JSON is available on http://0.0.0.0:8080/api-docs-auth/swagger.json
[2019-01-21T08:14:38.635] [INFO ] [TSED] - [api-auth] Swagger UI is available on http://0.0.0.0:8080/api-docs-auth/
Server is ready and listen the port
[2019-01-21T08:14:38.636] [INFO ] [TSED] - Started in 3952 ms
[2019-01-21T08:14:38.652] [INFO ] [TSED] - Connected with typeorm to database: default
[2019-01-21T08:14:39.579] [WARN ] [TSED] - Timeout on $onInit hook. Promise are unfulfilled on serviceTypeORMModule In production, the warning will down the server!
Reactions are currently unavailable