-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (28 loc) · 1002 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
33
34
35
36
37
38
39
40
'use strict';
const path = require('path');
const AV = require('leanengine');
const Koa = require('koa');
const Router = require('koa-router');
const views = require('koa-views');
const statics = require('koa-static');
const bodyParser = require('koa-bodyparser');
// Loads cloud function definitions.
// You can split it into multiple files but do not forget to load them in the main file.
require('./cloud');
const app = new Koa();
// Configures template engine.
app.use(views(path.join(__dirname, 'views')));
// Configures static resources directory.
app.use(statics(path.join(__dirname, 'public')));
const router = new Router();
app.use(router.routes());
// Loads LeanEngine middleware.
app.use(AV.koa());
app.use(bodyParser());
router.get('/', async function(ctx) {
ctx.state.currentTime = new Date();
await ctx.render('./index.ejs');
});
// You can store routings in multiple files according to their categories.
app.use(require('./routes/todos').routes());
module.exports = app;