UNPKG

558 BJavaScriptView Raw
1'use strict'
2
3var Hapi = require('hapi')
4
5// Create a server with a host and port
6var server = new Hapi.Server()
7server.connection({
8 host: 'localhost',
9 port: 8080
10})
11
12// Add the route
13server.route({
14 method: 'GET',
15 path: '/',
16 handler: function (request, reply) {
17 return reply('hello world')
18 }
19})
20
21server.register(require('hapi-pino'), function (err) {
22 if (err) {
23 console.error(err)
24 process.exit(1)
25 }
26
27 // Start the server
28 server.start(function (err) {
29 if (err) {
30 console.error(err)
31 process.exit(1)
32 }
33 })
34})