Created
April 14, 2019 10:42
-
-
Save Sean-Bradley/0343069e66a7437ee53c18c4da4a3c38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import express from 'express' | |
import Router from './router' | |
import swaggerUi from 'swagger-ui-express' | |
import * as swaggerDocument from './swagger.json' | |
import * as bodyParser from 'body-parser' | |
class App { | |
private httpServer: any | |
constructor() { | |
this.httpServer = express() | |
this.httpServer.use(bodyParser.urlencoded({ extended: true })); | |
this.httpServer.use(bodyParser.json()); | |
new Router(this.httpServer); | |
this.httpServer.use('/swagger', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); | |
} | |
public Start = (port: number) => { | |
return new Promise((resolve, reject) => { | |
this.httpServer.listen( | |
port, | |
() => { | |
resolve(port) | |
}) | |
.on('error', (err: object) => reject(err)); | |
}) | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment