-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (20 loc) · 760 Bytes
/
index.js
File metadata and controls
26 lines (20 loc) · 760 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
import express from "express";
import { __dirname } from "./utils.js";
import projectRoutes from "./routes/project.routes.js";
const app = express();
app.use(express.static("public"));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get("/node_modules/*", (req, res) => {
res.sendFile(`${__dirname}/${req.url}`);
});
app.use("/project", projectRoutes);
// обратите внимание: обработчик ошибок должен быть последним в цепочке посредников
app.use((err, req, res, next) => {
console.error(err.message || err);
res.sendStatus(err.status || 500);
});
const PORT = process.env.PORT || 6000;
app.listen(PORT, () => {
console.log(`🚀 -> ${PORT}`);
});