-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (37 loc) · 872 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
41
42
43
44
45
import express from "express";
import config from "./config/config.js";
import router from "./api/router.js";
import jobs from "./jobs/jobs.js";
async function startServer() {
const app = express();
app.use(express.static('public'));
app.use(express.urlencoded({ extended: true }));
app.use(router);
app
.listen(config.port, () => {
console.log(`
Server is doing server's best on port ${config.port}.`);
})
.on("error", (error) => {
console.error(error);
process.exit(1);
});
}
const runnable = process.argv[2] || "server";
switch (runnable) {
case "tweet":
await jobs.tweet();
break;
case "setupDb":
await jobs.setupDb();
break;
case "update":
await jobs.update();
break;
case "server":
startServer();
break;
default:
console.log("Stop messing with it.");
break;
}