forked from anuraghazra/github-readme-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpress.js
More file actions
45 lines (38 loc) · 1.18 KB
/
express.js
File metadata and controls
45 lines (38 loc) · 1.18 KB
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 "dotenv/config";
import statsCard from "./api/index.js";
import repoCard from "./api/pin.js";
import langCard from "./api/top-langs.js";
import wakatimeCard from "./api/wakatime.js";
import gistCard from "./api/gist.js";
import express from "express";
const app = express();
const port = process.env.PORT || process.env.port || 9000;
app.use((req, res, next) => {
console.log(`${new Date().toISOString()} ${req.method} ${req.url}`);
next();
});
app.get("/", statsCard);
app.get("/pin", repoCard);
app.get("/top-langs", langCard);
app.get("/wakatime", wakatimeCard);
app.get("/gist", gistCard);
app.get("/health", (req, res) => {
res.status(200).json({ status: "ok", timestamp: new Date().toISOString() });
});
const server = app.listen(port, () => {
console.log(`Server started on port ${port}, awaiting requests`);
});
process.on("SIGTERM", () => {
console.log("stopping, received SIGTERM signal");
server.close(() => {
console.log("server stopped gracefully");
process.exit(0);
});
});
process.on("SIGINT", () => {
console.log("stopping, received SIGINT signal");
server.close(() => {
console.log("server stopped gracefully");
process.exit(0);
});
});