-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 987 Bytes
/
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
const express = require('express');
const session = require('express-session');
const dotEnv = require('dotenv');
const connectMongoDBDatabase = require('./src/database/connections/mongodb');
const connectSequelizeDatabase = require('./src/database/connections/sequelize');
const app = express();
dotEnv.config();
const port = process.env.PORT || 3000;
const indexRoutes = require('./src/routes/indexRoutes');
//Using Express.JSON
app.use(express.json());
connectMongoDBDatabase();
connectSequelizeDatabase();
global.app = express();
global.secretKey = process.env.JWT_SECRET;
app.use(session({
secret: secretKey,
resave: true,
saveUninitialized: true
}));
//Routes
app.use("/", indexRoutes);
app.listen(port, () => {
console.log(`=============Node js Express Connect========================`)
console.log(`Server running on port: ${port}`);
console.log(`Server running on url: http://localhost:${port}`);
console.log(`============================================`)
})