ulduldp commited on
Commit
9ad447c
·
verified ·
1 Parent(s): ce6f0d1

Create index.js

Browse files
Files changed (1) hide show
  1. index.js +29 -0
index.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require("express");
2
+ const path = require("path");
3
+
4
+ const pingerRoutes = require("./routes/pinger.routes");
5
+ const scheduler = require("./services/scheduler.service");
6
+
7
+ const app = express();
8
+
9
+ app.use(express.json());
10
+ app.set("view engine", "ejs");
11
+ app.set("views", path.join(__dirname, "views"));
12
+
13
+ app.get("/", (req, res) => {
14
+ res.render("index", { status: "Running ✅" });
15
+ });
16
+
17
+ // health
18
+ app.get("/health", (req, res) => {
19
+ res.json({ status: "OK" });
20
+ });
21
+
22
+ // routes
23
+ app.use("/", pingerRoutes);
24
+
25
+ // start scheduler
26
+ scheduler.start();
27
+
28
+ const PORT = 8501;
29
+ app.listen(PORT, () => console.log("Server running on", PORT));