Files
DefinitelyTyped/types/shot/shot-tests.ts
Alexander James Phillips ae60b8ca46 Move hapi dependencies to own modules
catbox, h2o2, mime-db, mimos, podium, shot, vision
Add tests where possible.
Add note regarding apparent failure of some nested object literals to enforce typings
2017-05-07 15:04:37 +01:00

30 lines
641 B
TypeScript

// From: https://github.com/hapijs/shot#example
// Load modules
import Http = require('http');
import Shot = require('shot');
// Declare internals
const internals: any = {};
internals.main = function () {
const dispatch = function (req: Http.IncomingMessage, res: Http.ServerResponse) {
const reply = 'Hello World';
res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': reply.length });
res.end(reply);
};
const server = Http.createServer(dispatch);
Shot.inject(dispatch, { method: 'get', url: '/' }, (res) => {
console.log(res.payload);
});
};
internals.main();