-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
38 lines (31 loc) · 881 Bytes
/
index.ts
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
import "dotenv/config";
import middlewares from "./middlewares";
import router from "./routes";
import express from "express";
import { coinbase, sanctioned } from "./services";
const start = async () => {
let app = express();
app = middlewares(app);
app.use(router);
coinbase.setupCoinbase();
await sanctioned.setupOFACSanctionList();
sanctioned.setupSanctionCron();
app.listen(process.env.PORT || 5000, async () => {
try {
console.log(`🚀 Server running on port ${process.env.PORT || 5000}`);
} catch (error) {
await gracefulShutdown();
}
});
}
async function gracefulShutdown() {
try {
process.exit(0);
} catch (error) {
console.error(error);
process.exit(1);
}
}
process.on("SIGINT", gracefulShutdown);
process.on("SIGTERM", gracefulShutdown);
start();