-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (27 loc) · 980 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
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const cors = require('cors');
//const path = require('path');
//const session = require('express-session');
//const passport = require('passport');
const PORT = process.env.PORT || 5002;
//intialize
var app = express();
//get mongoose connection config
const db = require('./config/database');
mongoose.connect(db.mongoURI)
.then(() => console.log('MongoDB connected'))
.catch(err => console.log(err));
app.use(cors());
//app.use('/static', express.static(path.join(__dirname, '/static')));
//body-parser middleware
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
//bring user routes
const user = require('./routes/user');
app.use('/user', user);
//bring products route
const products = require('./routes/products');
app.use('/products', products);
app.listen(PORT, () => console.log(`SV started on port ${PORT}`));