-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (29 loc) · 1.12 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
require("dotenv").config();
const express = require("express");
const routes = require("./routes");
const APP_PORT = process.env.APP_PORT || 8000;
const app = express();
const productSeeder = require("./seeders/productSeeder.js");
const adminSeeder = require("./seeders/adminSeeder.js");
const categorySeeder = require("./seeders/categorySeeder.js");
const cors = require("cors");
const mongoose = require("./db/dbInitialSetup");
mongoose.connection
.once("open", () => console.log("¡Conexión con la base de datos establecida!"))
.on("error", (error) => console.log(error));
// (async function () {
// // await mongoose.connection.dropDatabase();
// await adminSeeder(mongoose);
// await categorySeeder(mongoose);
// await productSeeder(mongoose);
// console.log("La base de datos fue ejecutada");
// })();
app.use(cors());
app.use(express.static("public"));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
routes(app);
app.listen(APP_PORT, () => {
console.log(`\n[Express] Servidor corriendo en el puerto ${APP_PORT}.`);
console.log(`[Express] Ingresar a http://localhost:${APP_PORT}.\n`);
});