-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11146 from mbaluda-org/main
JS: Improved Hapi support
- Loading branch information
Showing
4 changed files
with
157 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* Added support for @hapi/glue and Hapi plugins to the frameworks/Hapi.qll library. |
50 changes: 50 additions & 0 deletions
50
javascript/ql/test/library-tests/frameworks/hapi/src/hapiglue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var server1 = new (require('@hapi/glue')).compose(require("./manifest"), composeOptions); // test_ServerDefinition | ||
|
||
var Hapi = require('@hapi/glue'); | ||
var server2 = new Hapi.compose(require("./manifest"), composeOptions); // test_ServerDefinition | ||
|
||
function handler1(){} // HTTP::RouteHandler | ||
server2.route({ | ||
handler: handler1 | ||
}); | ||
|
||
|
||
server2.route({ | ||
handler: function handler2(request, reply){ // HTTP::RouteHandler | ||
request.response.header('HEADER1', '') // HTTP::HeaderDefinition | ||
}}); | ||
|
||
server2.ext('onPreResponse', function handler3(request, reply) { // HTTP::RouteHandler | ||
}) | ||
|
||
function handler4(request, reply){ | ||
request.rawPayload; | ||
request.payload.foo; | ||
request.query.bar; | ||
request.params.bar; | ||
request.url.path; | ||
request.url.origin; | ||
request.headers.baz; | ||
request.state.token; | ||
} | ||
var route = {handler: handler4}; | ||
server2.route(route); | ||
|
||
server2.cache({ segment: 'countries', expiresIn: 60*60*1000 }); | ||
|
||
function getHandler() { | ||
return function (req, hapi){} | ||
} | ||
server2.route({handler: getHandler()}); | ||
|
||
function after(server) { | ||
}; | ||
|
||
function register(server, options) {// test_ServerDefinition | ||
server.dependency(options.dependencies, server_ => after(server_, options)); // test_ServerDefinition | ||
} | ||
|
||
module.exports.plugin = { | ||
register, | ||
pkg | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters