-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (23 loc) · 707 Bytes
/
server.js
File metadata and controls
31 lines (23 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
24
25
26
27
28
29
30
'use strict';
const Hapi = require('hapi');
const mongoose = require('mongoose');
const populate = require('./populate');
const Routes = require('./routes');
const server = new Hapi.Server();
server.connection({ port: process.env.PORT || 3000 });
const dbUrl = process.env.MONGODB || 'mongodb://localhost/inventory-node';
server.route(Routes);
mongoose.Promise = global.Promise;
mongoose.connect(dbUrl, {}, (mongooseErr) => {
if (mongooseErr) {
throw mongooseErr;
} else {
server.start(function (err) {
if (err) {
throw err;
}
console.log(`Server running at: ${server.info.uri}`);
});
populate();
}
});