-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (25 loc) · 891 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (25 loc) · 891 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 Hoek = require('hoek');
const Settings = require('./lib/settings');
const routes = require('./lib/routes');
// For authentication. Excluded for now
const users = require('./lib/temp/users'); // Temporary user for testing authentication
const validate = require('./lib/authentication')
const start = async () => {
try {
const server = new Hapi.Server({ port: Settings.port, host: Settings.host });
// Basic authentication. Excluded for now.
await server.register(require('hapi-auth-basic'));
server.auth.strategy('simple', 'basic', { validate });
//setup routes
server.route(routes);
//setup node server
await server.start();
console.log('server running at: ' + server.info.uri);
}
catch (err) {
Hoek.assert(!err, err);
}
};
start();