-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
79 lines (65 loc) · 1.76 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*jslint node: true, forin: true, jslint white: true, newcap: true*/
/*
* wrappify
* author : Takeshi Iwana
* https://github.com/iwatakeshi
* license : MIT
* Code heavily borrowed from Adam Draper
* https://github.com/adamwdraper
*/
(function() {
'use strict';
var wrappify,
hasModule = (typeof module !== 'undefined' && module.exports);
function Wrappify(core) {
'use strict';
this.core = core;
}
Wrappify.prototype.express = function() {
return this.core.ship.bind(this.core);
};
Wrappify.prototype.hapi = function() {
var core = this.core;
var plugin = {
register: function hapi(plugin, options, next) {
plugin.ext('onPreHandler', function(request, reply) {
core.ship.bind(core)(request);
reply.continue();
});
plugin.ext('onPreResponse', function(request, reply) {
core.ship.bind(core)(request);
reply.continue();
});
return next();
}
}
plugin.register.attributes = {
name: 'Wrappify',
version: '0.0.1'
}
return plugin;
};
wrappify = function(core) {
return new Wrappify(core);
};
/************************************
Exposing wrappify
************************************/
// CommonJS module is defined
if (hasModule) {
module.exports = wrappify;
}
/*global ender:false */
if (typeof ender === 'undefined') {
// here, `this` means `window` in the browser, or `global` on the server
// add `wrappify` as a global object via a string identifier,
// for Closure Compiler 'advanced' mode
this.wrappify = wrappify;
}
/*global define:false */
if (typeof define === 'function' && define.amd) {
define([], function() {
return wrappify;
});
}
}).call(this);