-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
72 lines (61 loc) · 2.08 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*------*\
SERVER
\*------*/
// Fastify
const logger = require('./logger');
const fastify = require('fastify')({logger});
// Renderer
fastify.register(require('point-of-view'), {
engine: {pug: require('pug')},
});
// Cookies
fastify.register(require('@fastify/cookie'), {
secret: process.env.COOKIE_SECRET,
});
// Routes
fastify.register(require('@fastify/formbody'));
fastify.register(require('./src/routes/email'));
fastify.register(require('./src/routes/launches'));
fastify.register(require('./src/routes/login'));
fastify.register(require('./src/routes/manage'));
fastify.register(require('./src/routes/static'));
fastify.register(require('./src/routes/titles'));
fastify.register(require('./src/routes/twsf'));
// Start server
fastify.listen(3000, (err, address) => {
logger.info(`Listening on ${address}`);
if (err) {
logger.error(err);
TootTweetJob.gracefulShutdown();
process.exit(1);
}
});
/*---*\
BOT
\*---*/
require('./bot');
/*----------------*\
SCHEDULED EVENTS
\*----------------*/
const schedule = require('node-schedule');
// Twitter
const storeNewTwsfTweets = require('./twsf/twitter/tweets');
const storeNewTwsfDirectMessages = require('./twsf/twitter/direct-messages');
// Mastodon
const storeNewTwsfToots = require('./twsf/mastodon/toots');
// Schedule twitter checks Sunday at 12pm EST. The intention is to schedule this
// at the start of the show. Twitter allows us to search the last thirty days of
// tweets, so we don't need to check more than once a week, but we want guesses
// available before the crew begins finalizing the show notes Sunday morning,
// then we should check again just before the show begins. Glitch server is in
// UTC.
const TootTweetJob = schedule.scheduleJob('0 13,16 * * 0', () => {
storeNewTwsfTweets().catch(logger.error);
storeNewTwsfDirectMessages().catch(logger.error);
storeNewTwsfToots().catch(logger.error);
});
// Increment episode
// const {incrementEpisode} = require("./database/suggestions");
// const incrementEpisodeJob = schedule.scheduleJob('', ()=>{
// incrementEpisode();
// })