-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (27 loc) · 852 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
let express = require('express'),
Dropbox = require('dropbox'),
Promisebox = require('./promisebox'),
Journal = require('./journal');
let client = new Dropbox.Client({
token: process.env.DROPBOX_AUTH_TOKEN
});
client.authDriver(new Dropbox.AuthDriver.NodeServer(8191));
client = new Promisebox(client);
let app = express();
app.set('view engine', 'jade');
app.get('/', async (req, res) => {
let entry;
try {
const journal = new Journal(client, process.env.AGENDRA_JOURNAL_PATH);
entry = await journal.latest();
} catch (error) {
console.log(error);
return res.send(error.response ? error.response.error : error);
}
const section = entry.section(/tomorrow/);
res.render('show', {
title: entry.date.clone().add(1, 'day').format('LL'),
body: section.simplify().toHTML()
});
});
module.exports = app;