forked from eldroan/dan-ms-productos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
59 lines (47 loc) · 1.27 KB
/
server.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Express from "express";
import routerProductos from "./src/routes/ProductoRoutes.js";
import routerOrdenProvision from "./src/routes/OrdenProvisionRoutes.js";
import routerProveedores from "./src/routes/ProveedorRoutes.js";
import routerCategoria from "./src/routes/CategoriaRoutes.js";
import routerHealth from "./src/routes/HealthRoutes.js";
const PORT = process.env.PORT ?? 3000;
const app = Express();
app.use(Express.json());
app.get("/", (req, res) => {
res.json({
message: "Etapa 2 TP DAN corriendo",
});
});
//MIME type
app.use(
"/",
Express.static("public", {
setHeaders: (res, path) => {
if (path.endsWith(".js")) {
res.setHeader("Content-Type", "text/javascript");
}
},
})
);
//use de routers
app.use("/api/producto", routerProductos);
app.use("/api/orden", routerOrdenProvision);
app.use("/api/proveedor", routerProveedores);
app.use("/api/categoria", routerCategoria);
app.use('/api/health', routerHealth);
/*
app.use("/api/health", (req, res) => {
res.json({
app: "ms-productos",
status: "OK",
});
});
*/
app.use((req, res) => {
res.status(404).send("<h1>Página no encontrada (404)</h1>");
});
app.listen(PORT, () => {
console.log(
"Server escuchando en puerto http://localhost:" + PORT.toString()
);
});