forked from do-community/hello_hapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (25 loc) · 629 Bytes
/
app.js
File metadata and controls
35 lines (25 loc) · 629 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
31
32
33
34
35
'use strict';
const Hapi = require('@hapi/hapi');
const Server = new Hapi.Server({
host: 'localhost',
port: 3000
});
const Hello = require('./lib/hello');
Server.route({
method: 'GET',
path: '/hello/{user}',
handler: function (request, reply) {
const result = Hello(decodeURIComponent(request.params.user));
return result;
}
});
// don't start server if this file was required
if (!module.parent) {
Server.start((err) => {
if (err) {
throw err;
}
console.log(`Server running at: ${Server.info.uri}`);
});
}
module.exports = Server;