Skip to content

Instantly share code, notes, and snippets.

@NikolayGalkin
Created March 3, 2016 10:35
Show Gist options
  • Save NikolayGalkin/8b9ae83e89cc8bd4b9d0 to your computer and use it in GitHub Desktop.
Save NikolayGalkin/8b9ae83e89cc8bd4b9d0 to your computer and use it in GitHub Desktop.
import Koa from 'koa';
import logger from 'koa-logger';
import bodyparser from 'koa-bodyparser';
import error from 'koa-error';
import convert from 'koa-convert';
import Debug from 'debug';
import config from './lib/config';
import db from './lib/db';
import router from './lib/router';
export const app = module.exports = new Koa();
const debug = new Debug('app:main');
app.use(convert(error()));
app.use(logger());
app.use(bodyparser());
app.use(config(app));
app.use(db(app));
app.use(router(app));
if (!module.parent) {
app.listen(app.config.app.port, app.config.app.host, function cb() {
debug(`Listen ${app.config.app.host}:${app.config.app.port}`);
});
}
require('babel-core/register');
require('babel-polyfill');
const Debug = require('debug');
const app = require('./app');
const debug = new Debug('app:main');
app.listen(app.config.app.port, app.config.app.host, function cb() {
debug(`Listen ${app.config.app.host}:${app.config.app.port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment