-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (24 loc) · 758 Bytes
/
server.js
File metadata and controls
30 lines (24 loc) · 758 Bytes
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
import { handler } from "./build/handler.js";
import express from "express";
import helmet from "helmet";
import http from "http";
import { createTerminus } from "@godaddy/terminus";
const app = /** @type {express.Express} */ (express());
app.use(helmet.contentSecurityPolicy({
directives: {
"img-src": ["'self'", "https: data: blob:"],
"script-src": ["'self'", "'unsafe-inline'", "https:", "http:"],
}
}));
app.use(handler);
const server = /** @type {http.Server} */ (http.createServer(app));
createTerminus(server, {
signals: ['SIGTERM', 'SIGINT'],
onSignal: async () => {
// Call your cleanup functions below. For example:
// db.shutdown()
},
});
server.listen(3000, () => {
console.log("⚡ Listening on port 3000");
});