-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (22 loc) · 817 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const Koa = require('koa');
const app = new Koa();
const body = require('koa-body');
const glob = require('glob');
const helmet = require('koa-helmet');
const passport = require('koa-passport');
const path = require('path');
const config = require(path.resolve('./config/env/default'));
app.use(body()).use(passport.initialize());
app.use(helmet());
glob.sync('./modules/*/routes/*.js').forEach((file) => {
const routes = require(path.resolve(file)).routes();
app.use(routes);
});
app.keys = ['koa-jwt-postgres-auth'];
app.proxy = true;
app.listen(config.server.port);
console.log('\nKoa, JWT, and Postgres Authentication API\n');
console.log(`Environment: \t ${process.env.NODE_ENV}`);
console.log(`Port: \t\t ${config.server.port}`);
console.log(`\n${new Date().toString()}\n`);
module.exports = app;