-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (32 loc) · 1.1 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
const appDb = require("./appDb");
const sqlite = require("better-sqlite3");
require("dotenv").config();
const { execSync } = require("child_process");
const fs = require("fs");
const pokemon = require("pokemontcgsdk");
if (!fs.existsSync("./public/css")) {
fs.mkdirSync("./public/css", { recursive: true });
}
execSync(
"npx tailwindcss -i ./statics/css/styles.css -o ./public/css/styles.css"
);
if (process.env.POKEMON_TCG_API_TOKEN == undefined) {
console.log(
"Error: the env variable POKEMON_TCG_API_TOKEN is not set. Please grab a token here: https://pokemontcg.io/"
);
process.exit(1);
}
if (process.env.DISCORD_WEBHOOK_URL == undefined) {
console.log(
"Error: the env variable DISCORD_WEBHOOK_URL is not set. Learn how to set one up here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks"
);
process.exit(1);
}
pokemon.configure({ apiKey: process.env["POKEMON_TCG_API_TOKEN"] });
const scheduleJobs = require("./lib/scheduleJobs");
require("roosevelt")({
onServerInit: (app) => {
appDb.db = sqlite("data/data.db");
scheduleJobs();
},
}).startServer();