-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
81 lines (60 loc) · 1.92 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const connection = require("./database/connection");
const session = require("express-session");
//Controllers
const adminController = require("./class/item/itemController");
const itemController = require("./class/admin/adminController");
const sellerController = require("./class/seller/sellerController");
const monitoringController = require("./class/monitoring/monitoringController");
const promotionController = require("./class/promotion/promotionController");
const tipController = require("./class/tip/tipController");
//Models
const Item = require("./class/item/Item");
const Admin = require("./class/admin/Admin");
const Seller = require("./class/seller/Seller");
const Monitoring = require("./class/monitoring/Monitoring");
const Promotion = require("./class/promotion/Promotion");
const Tip = require("./class/tip/Tip");
//connection
connection
.authenticate()
.then(() => {
console.log('Conexão feita com o banco de dados.')
})
.catch((err) => {
console.log(err)
})
app.set('view engine', 'ejs');
app.use(express.static("public"));
//var path = require('path');
//app.use('/public',express.static(path.join(__dirname, 'public')));
//app.set('views', path.join(__dirname, '/views'));
//session
app.use(session({
secret: "az319kjudd894kid" , cookie: {} /*{maxAge: 24 * 60 * 60 * 1000} // 24 horas*/
}))
//body-parser
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
//rotas
//pagina Home
app.get('/', (req, res) => {
res.redirect("/items");
});
//Routers
app.use('/',adminController);
app.use('/',itemController);
app.use('/',sellerController);
app.use('/',monitoringController);
app.use('/',promotionController);
app.use('/',tipController);
//Iniciando o servidor
app.listen(3000,(err) =>{
if(err){
console.log(err)
}else{
console.log("Servidor iniciado com sucesso.")
}
});