-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (20 loc) · 746 Bytes
/
server.js
File metadata and controls
27 lines (20 loc) · 746 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
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const mongoose = require("mongoose");
const api = require("./server/routes/api");
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
mongoose.connect('mongodb://localhost/myappdatabase');
mongoose.connection.once('open', function(){
console.log('connection has been made !!!');
}).on('error', function(error){
console.log("connection error:"+error);
});
mongoose.Promise = global.Promise;
app.use(express.static(path.join(__dirname, 'dist')));
app.use('/api', api);
const server = app.listen(3000, ()=>{
console.log("Listening to port: "+server.address().port)
});