-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (25 loc) · 737 Bytes
/
index.js
File metadata and controls
30 lines (25 loc) · 737 Bytes
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
// Copyright (c) 2018, Livio, Inc.
require('dotenv').config(); //load environment
const Koa = require('koa');
const serve = require('koa-static');
const bodyParser = require('koa-bodyparser'); //for parsing JSON
const app = new Koa();
const config = require('./config');
//add ability to parse JSON from posts
app.use(bodyParser());
//serve Manticore webpage if enabled
if (!config.webpageDisabled) {
app.use(serve(__dirname + '/webpage'));
}
//setup all koa middleware under the selected version in /api
require(`./api/${config.apiVersion}`)(app);
//uncaught error handler
app.use(async (ctx, next) => {
try {
await next();
}
catch (err) {
console.error(err);
}
});
app.listen(config.httpPort);