-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (23 loc) · 941 Bytes
/
Copy pathapp.js
File metadata and controls
31 lines (23 loc) · 941 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
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const cors = require('cors');
const path = require('path');
const table = require('./routes/table');
const reservation = require('./routes/reservation');
const app = express();
mongoose.connect('mongodb://pky1139:password@ds111608.mlab.com:11608/trms'); //mLab
// mongoose.connect('mongodb://localhost/trms').catch(err => console.log(err));
mongoose.Promise = global.Promise;
app.use(express.static(path.join(__dirname, 'client', 'dist')));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.get('/', (req, res, err) =>{
res.sendFile(path.join(__dirname, 'client', 'dist/index.html'));
});
app.use('/api/table', table);
app.use('/api/reservation', reservation);
app.listen(process.env.PORT || 3000, () => {
console.log('Express listening for requests..');
});