Skip to content

Instantly share code, notes, and snippets.

@mentos1386
Created February 20, 2018 16:55
Show Gist options
  • Save mentos1386/dd22d7a5bf2004591c503dc0d87db1f8 to your computer and use it in GitHub Desktop.
Save mentos1386/dd22d7a5bf2004591c503dc0d87db1f8 to your computer and use it in GitHub Desktop.
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