-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
50 lines (32 loc) · 1.05 KB
/
index.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// This is the hapi plugin version to be included in other projects
// Dependencies
var Hapi = require('hapi');
var Hoek = require('hoek');
// Server Config
var config = require('./server/config');
// Hapi Server Plugins
var plugins = require('./server/config/plugins');
exports.register = function(server, options, next) {
//make config available to templates
server.ext('onPostHandler', function (request, reply) {
// Get the response object
var response = request.response;
if (request.response.variety === 'view') {
request.response.source.context = Hoek.applyToDefaults(config, request.response.source.context);
}
reply.continue();
});
server.register(plugins, function(err) {
if (err) return next(err);
// Make sure DB is available
server.dependency('dogwater');
server.route(require('./server/routes')(server, options));
server.views(config.hapi.options.views);
next();
});
};
var Package = require("./package.json");
exports.register.attributes = {
name: Package.name,
version: Package.version
}