-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.js
39 lines (33 loc) · 941 Bytes
/
web.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
33
34
35
36
37
38
39
'use strict';
const Koa = require('koa');
const app = new Koa();
const cors = require('@koa/cors');
const mount = require('koa-mount');
const koaStatic = require('koa-static');
const bodyparser = require('koa-bodyparser');
const mongoose = require('mongoose');
const cachegoose = require('cachegoose');
const index = require('./routes/index');
cachegoose(mongoose, {
port: 6379,
host: 'localhost',
});
mongoose.connect(process.env.TASKERBOT_MONGO_CRED);
// view engine setup
app.use(cors({
origin: [
'http://glyph.rollingglory.com',
'http://rollingtaskerbot.herokuapp.com',
'https://rgb-task.now.sh',
],
}));
app.use(koaStatic('taskerview'));
app.use(koaStatic('node_modules'));
app.use(bodyparser());
app.use(mount('/', index));
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', () => {
console.log('mongoose connected');
});
module.exports = app;