2017-08-16 19:49:27 +02:00
|
|
|
import bodyParser from 'koa-bodyparser';
|
|
|
|
import Koa from 'koa';
|
|
|
|
import logger from 'koa-logger';
|
|
|
|
import helmet from 'koa-helmet';
|
|
|
|
import routing from './routes/';
|
|
|
|
import { port } from './config';
|
2017-08-17 18:11:53 +02:00
|
|
|
import winston from 'winston';
|
|
|
|
|
|
|
|
// Setup logging
|
|
|
|
winston.remove(winston.transports.Console);
|
2017-08-18 10:16:29 +02:00
|
|
|
winston.add(winston.transports.Console, { colorize: true, timestamp: true, prettyPrint: true });
|
2017-08-16 19:49:27 +02:00
|
|
|
|
|
|
|
// Create Koa Application
|
|
|
|
const app = new Koa();
|
|
|
|
|
|
|
|
app
|
|
|
|
.use(logger())
|
|
|
|
.use(bodyParser())
|
|
|
|
.use(helmet());
|
|
|
|
|
|
|
|
routing(app);
|
|
|
|
|
|
|
|
// Start the application
|
2017-08-17 18:11:53 +02:00
|
|
|
app.listen(port, () => winston.log('info', `Lighthouse API server is running at http://localhost:${port}/`));
|
2017-08-16 19:49:27 +02:00
|
|
|
|
|
|
|
export default app;
|