-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (21 loc) · 707 Bytes
/
app.js
File metadata and controls
23 lines (21 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const config = require('./config/database');
const path = require('path');
mongoose.Promise =global.Promise;
mongoose.connect(config.uri, (err) => {
if(err){
console.log('Could NOT connect to database', err);
} else{
console.log('CONNECTED to ' + config.db + ' database!');
}
});
//access the client folder in dist folder
app.use(express.static(__dirname + '/client/dist'));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/dist/index.html'));
});
app.listen(8080, () =>{
console.log('Listening on port 8080') ;
});