-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (31 loc) · 971 Bytes
/
server.js
File metadata and controls
38 lines (31 loc) · 971 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
27
28
29
30
31
32
33
34
35
36
37
38
//IMPORTACOES
const express = require("express");
const { db, setupDatabase} = require("./mysql-init");
const app = express();
app.use(express.json());
app.use(express.static('public'));
app.use(require('cors')());
//Importando config do ENV
require("dotenv").config();
const PORT = process.env.PORT;
// Importando ROTAS
const rotasGerais = require("./routes/routes");
const rotasEstoque = require("./routes/estoque");
const rotasVendas = require("./routes/vendas");
const analiseRoutes = require("./routes/analise");
//Importando Banner
const banner = require("./chalk");
app.use("/analise", analiseRoutes);
app.use("/", rotasGerais);
app.use("/estoque", rotasEstoque);
app.use("/vendas", rotasVendas);
console.clear()
app.listen(PORT || 4000, () => {
banner();
console.log(`Server rodando na porta ${PORT} com MySQL.`);
});
setupDatabase();
// ROTA INICIAL
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});