-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (24 loc) · 551 Bytes
/
server.js
File metadata and controls
28 lines (24 loc) · 551 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
import express from "express";
import Router from "./routers/router.js";
import cors from "cors";
const app = express();
app.use(cors({
origin: '*',
methods: ['GET', 'POST', 'PUT']
}))
app.use(express.json());
app.use("/", Router);
app.get("/test", (req, res) => {
try {
res.status(200).json({ message: "Healthy" });
} catch (err) {
res.status(500).json({ message: err.message });
}
});
const port = 8080;
app.listen(port, (err) => {
if (err) {
console.log(err);
}
console.info("Server running on port %s.", port);
});