-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
40 lines (27 loc) · 954 Bytes
/
index.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
require('dotenv').config();
const express = require('express');
const notion = require('./notion.js');
const bannerbear = require('./bannerbear.js');
const calendar = require('./calendar.js');
var app = express();
var todoTasks;
app.get('/', (req, res) => {
res.send('Hello Express app!')
});
app.listen(3000, () => {
console.log('server started');
});
app.get('/notion-todo-wallpaper', async (req, res) => {
var hasChange = false;
var imageUrl = '';
// Step 1. Get the To-do List from the Notion Database
var result = await notion.getTodoTasks();
var hasChange = JSON.stringify(todoTasks) !== JSON.stringify(result);
const calendarObj = await calendar.getCurrentMonthCalendar();
// Step 2. Generate a Wallpaper Using Bannerbear
if (hasChange) {
imageUrl = await bannerbear.generateWallpaper(result, calendarObj);
}
todoTasks = result;
res.send(JSON.stringify({ hasChange: hasChange, imageUrl: imageUrl }));
})