-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (43 loc) · 1.63 KB
/
index.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
const express = require("express");
const cors = require("cors");
const { PORT } = require("./config");
const firebase = require("./config/firebase");
//const db = require("./db/index.js");
const categoriaRouter = require("./routes/CategoriaRouter");
const materialRouter = require("./routes/MaterialRouter");
const modeloRouter = require("./routes/ModeloRouter");
const fotoRouter = require("./routes/FotoRouter");
const productoRouter = require("./routes/ProductoRouter");
const ofertaRouter = require("./routes/OfertaRouter");
const usuarioRouter = require("./routes/UsuarioRouter");
const loginRouter = require("./routes/LoginRouter");
const rolRouter = require("./routes/RolRouter");
const facturaRouter = require("./routes/FacturaRouter");
const app = express();
app.use(
cors({
origin: "*",
})
);
app.use(express.json());
app.get("/api", (_, res) => {
res.json({ message: "Hello from server!" });
});
app.use("/api/categorias", categoriaRouter);
app.use("/api/materiales", materialRouter);
app.use("/api/modelos", modeloRouter);
app.use("/api/fotos", fotoRouter);
app.use("/api/productos", productoRouter);
app.use("/api/ofertas", ofertaRouter);
app.use("/api/usuarios", usuarioRouter);
app.use("/api/auth", loginRouter);
app.use("/api/rol", rolRouter);
app.use("/api/facturas", facturaRouter);
app.all('*', (req, res) => {
res.status(404).send({ message: "ruta invalida" });
})
app.listen(PORT, () => {
console.log(`Server start with port ${PORT}`);
});
//const { sendEmail } = require("./utils/sendEmail");
//sendEmail({destination : "[email protected]", subject : "prueba", text : "Prueba de envio de correo"});