Created
February 20, 2018 16:55
-
-
Save mentos1386/dd22d7a5bf2004591c503dc0d87db1f8 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
async function bootstrap(): Promise<void> { | |
// create koa app | |
const app = new Koa(); | |
const router = new Router(); | |
// create connection with database | |
// note that its not active database connection | |
// TypeORM creates you connection pull to uses connections from pull on your requests | |
const connection = await createConnection(); | |
// register all application routes | |
AppRoutes.forEach(route => router[route.method](route.path, route.action)); | |
// run app | |
app.use(bodyParser()); | |
app.use(router.routes()); | |
app.use(router.allowedMethods()); | |
const server = await app.listen(3000) | |
console.log('Koa application is up and running on port 3000'); | |
// Return server instance | |
return server; | |
} | |
export default bootstrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment