-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
31 lines (24 loc) · 862 Bytes
/
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
var _ = require('lodash');
exports.register = function (server, options, next) {
var environment = process.env.NODE_ENV || 'development';
// Hook onto the 'onPostHandler'
server.ext('onPostHandler', function (request, reply) {
// Get the response object
var response = request.response;
// Check to see if the response is a view
if (response.variety === 'view') {
if(_.isEmpty(response.source.context)){
response.source.context = {};
}
if(_.isEmpty(response.source.context.assets)){
response.source.context.assets = {};
}
response.source.context.assets = options[environment];
}
return reply.continue();
});
return next();
};
exports.register.attributes = {
pkg: require("./package.json")
};