mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
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
30 lines
641 B
TypeScript
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();
|