Skip to content

Instantly share code, notes, and snippets.

@jeff-kilbride
Created Oct 17, 2017
Embed
What would you like to do?
Server startup
'use strict';
const Confidence = require('confidence'),
Glue = require('glue'),
Config = require('./config');
const store = new Confidence.Store(Config),
manifest = store.get('/Glue', { env: process.env.NODE_ENV || 'local' });
const options = {
relativeTo: __dirname,
preRegister: function (server, next) {
// Add the runtime environment to the server.app object.
server.app.env = process.env.NODE_ENV || 'local';
// Add the Confidence store to the server.app object.
server.app.store = store;
next();
}
};
Glue.compose(manifest, options, async function (err, server) {
if (err) throw err;
await server.start();
server.log(['startup'], `Hapi server version ${server.version} started at ${server.info.uri}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment