import 'reflect-metadata' ; import { InversifyExpressServer } from 'inversify-express-utils' ; import { Container } from 'inversify' ; import { makeLoggerMiddleware } from 'inversify-logger-middleware' ; import * as bodyParser from 'body-parser' ; import * as helmet from 'helmet' ; import TYPES from './constant/types' ; import { UserService } from './service/user' ; import { MongoDBClient } from './utils/mongodb/client' ; import './controller/home' ; import './controller/user' ; let container = new Container ( ) ; if ( process . env . NODE_ENV === 'development' ) { let logger = makeLoggerMiddleware ( ) ; container . applyMiddleware ( logger ) ; } container . bind < MongoDBClient > ( TYPES . MongoDBClient ) . to ( MongoDBClient ) ; container . bind < UserService > ( TYPES . UserService ) . to ( UserService ) ; let server = new InversifyExpressServer ( container ) ; server . setConfig ( ( app ) => { app . use ( bodyParser . urlencoded ( { extended : true } ) ) ; app . use ( bodyParser . json ( ) ) ; app . use ( helmet ( ) ) ; } ) ; let app = server . build ( ) ; app . listen ( 3000 ) ; console . log ( 'Server started on port 3000 :)' ) ; exports = module . exports = app ;