-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
36 lines (30 loc) · 919 Bytes
/
app.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
import "dotenv/config"; //dotenv.config();
import express from "express";
import cors from "cors";
import dbConnectNoSql from "./config/mongo.js";
import { dbConnectMysql } from "./config/mysql.js";
import routes from "./routes/index.js"; //vistas
import morganBody from "morgan-body";
import loggerStream from "./utils/handleLogger.js";
const app = express();
const PORT = process.env.PORT_APP || 3002;
const ENGINE_DB = process.env.ENGINE_DB;
/**
* Aqui invocamos las rutas!
*/
//Leer informacion por la terminal morgan, envio a slack
morganBody(app, {
noColors: true,
stream: loggerStream,
skip: function (req, res) {
return res.statusCode < 400;
},
});
app.use(express.static("storage"));
app.use(express.json());
app.use(cors());
app.use("/api", routes);
app.listen(PORT, () => {
console.log(`Server run in the port ${PORT}`);
});
ENGINE_DB === "nosql" ? dbConnectNoSql() : dbConnectMysql();