-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (30 loc) · 936 Bytes
/
server.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
37
38
39
var path = require('path');
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var serveStatic = require('serve-static')
var routes = require('./routes')
// Create a new express app.
var app = express();
// Use the 'pub' template engine
app.set('view engine', 'pug');
// Set config variables
var port = process.env.PORT || 8080;
var ip = process.env.IP || '127.0.0.1';
var dbhost = process.env.IP || 'localhost'
var dbname = 'bookmark-manager';
// Connect to mongoose server.
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://' + dbhost + '/' + dbname);
// Serve files in 'public' as static files
app.use(serveStatic('public'))
// Parse the body of 'post' requests
app.use(bodyParser.urlencoded({
extended: false
}));
// Set up the routes
app.use(routes);
// Start the server
app.listen(port, ip, function() {
console.log("Bookmark service up!");
});