-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (26 loc) · 869 Bytes
/
index.js
File metadata and controls
35 lines (26 loc) · 869 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
32
const express=require('express');
const app=express();
const router=express.Router();
const mongoose = require("mongoose");
const config=require("./config/database");
const path=require('path');
const authentication=require('./routes/authentication')(router);
const bodyParser=require('body-parser');
mongoose.promise=global.promise;
mongoose.connect(config.uri,(err)=>{
if(err){
console.log('could not connect to database:',err);
}else{
console.log('connected to database:'+config.db);
}
});
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(express.static(__dirname+'/client/dist/client/'));
app.use('/authentication',authentication);
app.get('*',(req,res)=>{
res.sendFile(path.join(__dirname+'/client/dist/client/index.html'));
});
app.listen(8080,()=>{
console.log("Listening on port 8080");
});