Permalink
Browse files

Step 1.9: Register ednpoints routes

  • Loading branch information...
DAB0mB committed Dec 12, 2016
1 parent 186a056 commit 230fbfebb7c444a0be6106b70fda914693bb636e
Showing with 20 additions and 2 deletions.
  1. +20 −2 server.js
@@ -1,11 +1,23 @@
const Async = require("async");
const Hapi = require("hapi");
const Inert = require("inert");
const Endpoints = require("./routes/endpoints");
const IpGrabber = require("./helpers/ip_grabber");

let localIp = IpGrabber.local();
let port = 8000;

// Initialize a new server
let server = new Hapi.Server();
let server = new Hapi.Server({
connections: {
routes: {
files: {
// Served files will be relative to current directory
relativeTo: __dirname
}
}
}
});

server.connection({ port: process.env.PORT || port });

@@ -24,8 +36,14 @@ server.ext("onPreResponse", (req, rep) => {
rep.continue();
});

// Register all routes and plug-ins
Async.series([
next => server.register(Inert, next),
next => server.register(Endpoints, next),
// Once registrations are finished, start the server
next => server.start(next)
// Print message once started
server.start((err) => {
], (err) => {
if (err) throw err;

console.log();

0 comments on commit 230fbfe

Please sign in to comment.