Skip to content

Instantly share code, notes, and snippets.

@Sean-Bradley
Created April 14, 2019 10:42
Show Gist options
  • Save Sean-Bradley/0343069e66a7437ee53c18c4da4a3c38 to your computer and use it in GitHub Desktop.
Save Sean-Bradley/0343069e66a7437ee53c18c4da4a3c38 to your computer and use it in GitHub Desktop.
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