-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8136a1
commit a94afe6
Showing
1 changed file
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
'use strict'; | ||
|
||
const Hapi = require('hapi'); | ||
const hapijsStatusMonitor = require('hapijs-status-monitor'); | ||
|
||
// Create a server with a host and port | ||
const server = new Hapi.Server(); | ||
server.connection({ | ||
host: 'localhost', | ||
port: 8000 | ||
port: 8000, | ||
}); | ||
|
||
server.register({ | ||
register: require('hapijs-status-monitor') | ||
}); | ||
server.register({ register: hapijsStatusMonitor }); | ||
|
||
// Add the "/return-status/{statusCode}" route | ||
server.route({ | ||
method: 'GET', | ||
path: '/return-status/{statusCode}', | ||
handler: function (request, reply) { | ||
handler: function handler(request, reply) { | ||
const statusCode = request.params.statusCode; | ||
|
||
return reply(statusCode).code(parseInt(statusCode)); | ||
} | ||
return reply(statusCode).code(parseInt(statusCode, 10)); | ||
}, | ||
}); | ||
|
||
// Start the server | ||
server.start((err) => { | ||
if (err) throw err; | ||
console.log('Server running at:', server.info.uri); | ||
console.log('Server running at:', server.info.uri); // eslint-disable-line no-console | ||
}); |