-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
49 lines (43 loc) · 1.21 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
/**
* IMPORT EXTERNAL
*/
const express = require('express');
const app = express();
const body = require('body-parser');
const bodyParser = body.urlencoded({extended: false});
const mongoose = require('mongoose');
const session = require('express-session');
/**
* config session
*/
app.use(session({
secret: 'alsdh93e9d927d',
resave: false,
saveUninitialized: true,
cookie: { maxAge: 10000 }
}));
/**
* IMPORT INTERNAL
*/
const accountRoute = require('./src/controllers/users');
const productRoute = require('./src/controllers/products');
const transactionRoute = require('./src/controllers/transactions');
const viewRoute = require('./src/controllers');
/**
* APP CONFIG
*/
app.set('views', './views');
app.set('view engine', 'ejs');
app.use(express.static('./public'));
app.use(bodyParser);
app.use(body.json());
app.use('/api/v.1', viewRoute);
app.use('/api/v.1/product', productRoute);
app.use('/api/v.1/account', accountRoute);
app.use('/api/v.1/transaction', transactionRoute);
const port = process.env.PORT || 9256;
const uri = 'mongodb://localhost/nami-hackathon'
mongoose.connect(uri);
mongoose.connection.once('open', ()=>{
app.listen(port, ()=> console.log(`Server started at port ${port}`));
})