Move v16 types to ./v16 folder.

This commit is contained in:
rafaelsouzaf
2017-12-13 22:27:07 -03:00
parent 51e0b2b92b
commit 39d8d03a0f
84 changed files with 3270 additions and 2915 deletions
+55 -2708
View File
File diff suppressed because it is too large Load Diff
+58 -12
View File
@@ -1,30 +1,76 @@
// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents
// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents
import {
Lifecycle,
Request,
ResponseToolkit,
RouteOptions,
Server,
ServerOptions,
ServerRoute
} from "hapi";
import * as Crypto from 'crypto';
// From https://hapijs.com/api/16.1.1#requestsetmethodmethod
const options: ServerOptions = {
port: 8000,
};
import * as Hapi from 'hapi';
const Crypto = require('crypto');
const server = new Hapi.Server();
server.connection({ port: 80 });
const serverRoute: ServerRoute = {
path: '/',
method: 'GET',
handler: (request: Request, h: ResponseToolkit) => {
return 'ok: ' + request.path;
}
};
const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) {
const onRequest: Lifecycle.Method = (request: Request, h: ResponseToolkit) => {
/*
* Server events
*/
request.server.events.on('request', (request: Request, event: any, tags: any) => {
console.log(request.paramsArray);
console.log(event);
console.log(tags);
});
request.server.events.on('response', (request: Request) => {
console.log('Response sent for request: ' + request.path);
});
request.server.events.on('start', (route: RouteOptions) => {
console.log('Server started');
});
request.server.events.once('stop', (route: RouteOptions) => {
console.log('Server stoped');
});
/*
* Request events
*/
const hash = Crypto.createHash('sha1');
request.on('peek', (chunk) => {
request.events.on("peek", (chunk: any) => {
hash.update(chunk);
});
request.once('finish', () => {
request.events.once("finish", () => {
console.log(hash.digest('hex'));
});
request.once('disconnect', () => {
request.events.once("disconnect", () => {
console.error('request aborted');
});
return reply.continue();
return h.continue;
};
const server = new Server(options);
server.route(serverRoute);
server.ext('onRequest', onRequest);
server.start();
console.log('Server started at: ' + server.info.uri);
+25 -8
View File
@@ -1,12 +1,29 @@
// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data
import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi";
// From https://hapijs.com/api/16.1.1#requestgetlogtags-internal
const options: ServerOptions = {
port: 8000,
};
import * as Hapi from 'hapi';
const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => {
request.log(['test', 'error'], 'Test event');
return 'path: ' + request.path;
};
var request: Hapi.Request = <any> {};
const serverRoute: ServerRoute = {
path: '/',
method: 'GET',
handler: handler
};
request.getLog();
request.getLog('error');
request.getLog(['error', 'auth']);
request.getLog(['error'], true);
request.getLog(false);
const server = new Server(options);
server.route(serverRoute);
server.start();
console.log('Server started at: ' + server.info.uri);
server.events.on('request', (request: Request, event: any, tags: any) => {
console.log(tags);
if (tags.error) {
console.log(event);
}
});
+26 -20
View File
@@ -1,25 +1,31 @@
// https://github.com/hapijs/hapi/blob/master/API.md#errors
import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi";
import * as Boom from "boom";
// From https://hapijs.com/api/16.1.1#error-response
const options: ServerOptions = {
port: 8000,
};
import * as Hapi from 'hapi';
const Boom = require('boom');
const serverRoutes: ServerRoute[] = [
{
path: '/badRequest',
method: 'GET',
handler: (request: Request, h: ResponseToolkit) => {
throw Boom.badRequest('Unsupported parameter');
}
},
{
path: '/internal',
method: 'GET',
handler: (request: Request, h: ResponseToolkit) => {
throw new Error('unexpect error');
}
},
];
const server = new Hapi.Server();
server.route({
method: 'GET',
path: '/badRequest',
handler: function (request, reply) {
const server = new Server(options);
server.route(serverRoutes);
return reply(Boom.badRequest('Unsupported parameter'));
}
});
server.route({
method: 'GET',
path: '/internal',
handler: function (request, reply) {
return reply(new Error('unexpect error'));
}
});
server.start();
console.log('Server started at: ' + server.info.uri);
+22 -16
View File
@@ -1,46 +1,52 @@
'use strict';
import {Request, ResponseToolkit, RouteOptions, Server, ServerOptions, ServerRoute} from "hapi";
import * as Hapi from 'hapi';
const options: ServerOptions = {
port: 8000,
};
// different methods
var routeConfig: Hapi.RouteConfiguration = {
var routeConfig: ServerRoute = {
path: '/signin',
method: 'PUT',
vhost: 'site.coms',
};
var routeConfig: Hapi.RouteConfiguration = {
var routeConfig: ServerRoute = {
path: '/signin',
method: '*'
};
var routeConfig: Hapi.RouteConfiguration = {
var routeConfig: ServerRoute = {
path: '/signin',
method: ['OPTIONS', '*']
};
// different handlers
var routeConfig: Hapi.RouteConfiguration = {
var routeConfig: ServerRoute = {
path: '/signin',
method: 'PUT',
handler: 'some registered handler'
handler: (request: Request, h: ResponseToolkit) => {
return 'ok';
}
};
var routeConfig: Hapi.RouteConfiguration = {
var routeConfig: ServerRoute = {
path: '/signin',
method: 'PUT',
handler: function (request, reply) {
return reply('ok');
handler: (request: Request, h: ResponseToolkit) => {
return 'ok';
}
};
const server = new Hapi.Server();
const server = new Server(options);
server.route(routeConfig);
// Handler in config
const user: Hapi.RouteAdditionalConfigurationOptions = {
const user: RouteOptions = {
cache: { expiresIn: 5000 },
handler: function (request, reply) {
return reply({ name: 'John' });
handler: (request: Request, h: ResponseToolkit) => {
return { name: 'John' };
}
};
server.route({method: 'GET', path: '/user', config: user });
server.route({method: 'GET', path: '/user', options: user });
server.start();
console.log('Server started at: ' + server.info.uri);
+42 -71
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictNullChecks": false,
"strictFunctionTypes": false,
"baseUrl": "../",
"typeRoots": [
@@ -18,80 +18,51 @@
},
"files": [
"index.d.ts",
"test/connection/table.ts",
"test/continuation/errors.ts",
"test/getting-started/01-creating-a-server.ts",
"test/getting-started/02-adding-routes.ts",
"test/getting-started/03-serving-static-content.ts",
"test/getting-started/04-using-plugins.ts",
"test/path/catch-all.ts",
"test/path/parameters.ts",
"test/plugins/options.ts",
"test/reply/continue.ts",
"test/reply/entity.ts",
"test/reply/redirect.ts",
"test/reply/reply.ts",
"test/reply/state_cookie.ts",
"test/request/catch-all.ts",
"test/request/event-types.ts",
"test/request/generate-response.ts",
"test/request/get-log.ts",
"test/request/log.ts",
"test/request/parameters.ts",
"test/request/query.ts",
"test/request/set-method.ts",
"test/request/set-url.ts",
"test/request/tail.ts",
"test/response/error-representation.ts",
"test/response/continue.ts",
"test/response/error.ts",
"test/response/events.ts",
"test/response/flow-control.ts",
"test/route/additional-options.ts",
"test/route/auth.ts",
"test/response/redirect.ts",
"test/response/response.ts",
"test/response/response-events.ts",
"test/route/adding-routes.ts",
"test/route/config.ts",
"test/route/handler.ts",
"test/route/plugins.ts",
"test/route/prerequisites.ts",
"test/route/public-interface.ts",
"test/route/validate.ts",
"test/server/app.ts",
"test/server/auth.ts",
"test/server/bind.ts",
"test/server/cache.ts",
"test/server/connection-options.ts",
"test/server/connections.ts",
"test/server/decoder.ts",
"test/server/decorate.ts",
"test/server/dependency.ts",
"test/server/emit.ts",
"test/server/encoder.ts",
"test/server/event.ts",
"test/server/expose.ts",
"test/server/ext.ts",
"test/server/handler.ts",
"test/server/info.ts",
"test/server/initialize.ts",
"test/server/inject.ts",
"test/server/listener.ts",
"test/server/load.ts",
"test/server/log.ts",
"test/server/lookup.ts",
"test/server/match.ts",
"test/server/method.ts",
"test/server/methods.ts",
"test/server/mime.ts",
"test/server/new.ts",
"test/server/on.ts",
"test/server/once.ts",
"test/server/path.ts",
"test/server/plugins.ts",
"test/server/realm.ts",
"test/server/register.ts",
"test/server/route.ts",
"test/server/select.ts",
"test/server/settings.ts",
"test/server/start.ts",
"test/server/state.ts",
"test/server/stop.ts",
"test/server/table.ts",
"test/server/version.ts"
"test/route/route-options.ts",
"test/route/route-options-pre.ts",
"test/server/server-app.ts",
"test/server/server-auth-api.ts",
"test/server/server-auth-default.ts",
"test/server/server-auth-test.ts",
"test/server/server-bind.ts",
"test/server/server-cache.ts",
"test/server/server-cache-provision.ts",
"test/server/server-decoder.ts",
"test/server/server-decorations.ts",
"test/server/server-encoder.ts",
"test/server/server-events.ts",
"test/server/server-events-once.ts",
"test/server/server-expose.ts",
"test/server/server-info.ts",
"test/server/server-inject.ts",
"test/server/server-listener.ts",
"test/server/server-load.ts",
"test/server/server-lookup.ts",
"test/server/server-match.ts",
"test/server/server-method.ts",
"test/server/server-methods.ts",
"test/server/server-mime.ts",
"test/server/server-options.ts",
"test/server/server-path.ts",
"test/server/server-plugins.ts",
"test/server/server-settings.ts",
"test/server/server-start.ts",
"test/server/server-state.ts",
"test/server/server-stop.ts",
"test/server/server-table.ts",
"test/server/server-version.ts"
]
}
}
+2723
View File
File diff suppressed because it is too large Load Diff
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servertablehost
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80, host: 'example.com' });
server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } });
@@ -1,6 +1,6 @@
import * as Hapi from 'hapi';
import * as Boom from 'boom';
import * as Hapi from '../../';
import * as Boom from '../../../../boom';
// Assignment of a typical function to ContinuationValueFunction is possible
const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null, value?: any) => {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#catch-all-route
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#path-parameters
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverinfo
import * as Hapi from 'hapi';
import * as Hapi from '../../';
// added in addition to code from docs
interface PluginOptions {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#replycontinueresult
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#replyentityoptions
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#replyredirecturi
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const handler: Hapi.RouteHandler = function (request, reply) {
return reply.redirect('http://example.com');
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#replyerr-result
import * as Hapi from 'hapi';
import * as Hapi from '../../';
// verbose notation
@@ -19,4 +19,4 @@ const handler2: Hapi.RouteHandler = function (request, reply) {
return reply('success')
.type('text/plain')
.header('X-Custom', 'some-value');
};
};
@@ -1,7 +1,7 @@
// from https://hapijs.com/tutorials/cookies?lang=en_US
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -0,0 +1,30 @@
// From https://hapijs.com/api/16.1.1#requestsetmethodmethod
import * as Hapi from '../../';
const Crypto = require('crypto');
const server = new Hapi.Server();
server.connection({ port: 80 });
const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) {
const hash = Crypto.createHash('sha1');
request.on('peek', (chunk) => {
hash.update(chunk);
});
request.once('finish', () => {
console.log(hash.digest('hex'));
});
request.once('disconnect', () => {
console.error('request aborted');
});
return reply.continue();
};
server.ext('onRequest', onRequest);
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options
import * as Hapi from 'hapi';
import * as Hapi from '../../';
// Added in addition to code from docs
function promiseMethod() {
+12
View File
@@ -0,0 +1,12 @@
// From https://hapijs.com/api/16.1.1#requestgetlogtags-internal
import * as Hapi from '../../';
var request: Hapi.Request = <any> {};
request.getLog();
request.getLog('error');
request.getLog(['error', 'auth']);
request.getLog(['error'], true);
request.getLog(false);
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80, routes: { log: true, security: false } });
+14
View File
@@ -0,0 +1,14 @@
// Added test in addition to docs, for request.query
import * as Hapi from '../../';
interface GetThingQuery {
name: string;
}
const handler: Hapi.RouteHandler = function (request, reply) {
const query = request.query as GetThingQuery;
return reply(`You asked for ${query.name}`);
};
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#requestsetmethodmethod
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -17,7 +17,7 @@ server.ext('onRequest', onRequest);
// Example 2
const Url = require('url');
const Qs = require('qs');
const Qs = require('../../../../qs');
onRequest = function (request, reply) {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#requestsetmethodmethod
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,13 +1,13 @@
// From https://hapijs.com/api/16.1.1#error-transformation
import * as Hapi from 'hapi';
import Vision from 'vision';
import * as Hapi from '../../';
import Vision from '../../../../vision';
const server = new Hapi.Server();
server.register(Vision, {}, (err) => {
server.views({
engines: {
html: require('handlebars')
html: require('../../../../handlebars')
}
});
});
+25
View File
@@ -0,0 +1,25 @@
// From https://hapijs.com/api/16.1.1#error-response
import * as Hapi from '../../';
const Boom = require('../../../../boom');
const server = new Hapi.Server();
server.route({
method: 'GET',
path: '/badRequest',
handler: function (request, reply) {
return reply(Boom.badRequest('Unsupported parameter'));
}
});
server.route({
method: 'GET',
path: '/internal',
handler: function (request, reply) {
return reply(new Error('unexpect error'));
}
});
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#response-events
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const Crypto = require('crypto');
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#flow-control
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const handler = function (request: Hapi.Request, reply: Hapi.ReplyWithContinue) {
@@ -1,6 +1,6 @@
'use strict';
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var authConfig: Hapi.RouteAdditionalConfigurationOptions = {
app: {},
@@ -1,6 +1,6 @@
'use strict';
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var routeMoreConfig: Hapi.RouteAdditionalConfigurationOptions = {
auth: false,
+46
View File
@@ -0,0 +1,46 @@
'use strict';
import * as Hapi from '../../';
// different methods
var routeConfig: Hapi.RouteConfiguration = {
path: '/signin',
method: 'PUT',
vhost: 'site.coms',
};
var routeConfig: Hapi.RouteConfiguration = {
path: '/signin',
method: '*'
};
var routeConfig: Hapi.RouteConfiguration = {
path: '/signin',
method: ['OPTIONS', '*']
};
// different handlers
var routeConfig: Hapi.RouteConfiguration = {
path: '/signin',
method: 'PUT',
handler: 'some registered handler'
};
var routeConfig: Hapi.RouteConfiguration = {
path: '/signin',
method: 'PUT',
handler: function (request, reply) {
return reply('ok');
}
};
const server = new Hapi.Server();
server.route(routeConfig);
// Handler in config
const user: Hapi.RouteAdditionalConfigurationOptions = {
cache: { expiresIn: 5000 },
handler: function (request, reply) {
return reply({ name: 'John' });
}
};
server.route({method: 'GET', path: '/user', config: user });
+10
View File
@@ -0,0 +1,10 @@
'use strict';
import * as Hapi from '../../';
var handler: Hapi.RouteHandler = function(request, reply) {
reply('success');
}
var strictHandler: Hapi.RouteHandler = function(request, reply) {
reply(123);
}
@@ -1,9 +1,9 @@
// Added in addition to code from https://hapijs.com/api/16.1.1#route-options > plugins
import * as Hapi from 'hapi';
import * as Hapi from '../../';
// In the plugin code
declare module 'hapi' {
declare module '../../' {
interface PluginSpecificConfiguration {
coolPlugin: {
optionA: string;
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#route-prerequisites
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,6 +1,6 @@
'use strict';
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var route = <Hapi.RoutePublicInterface> {};
@@ -1,8 +1,8 @@
// Added from: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-302216131
import * as Hapi from 'hapi';
import * as Joi from 'joi';
import * as Hapi from '../../';
import * as Joi from '../../../../joi';
const validate: Hapi.RouteValidationConfigurationObject = {
headers: true,
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverapp
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var server = new Hapi.Server();
server.app.key = 'value';
@@ -1,8 +1,8 @@
// From https://hapijs.com/api/16.1.1#serverauthapi
import * as Hapi from 'hapi';
import * as Boom from 'boom';
import * as Hapi from '../../';
import * as Boom from '../../../../boom';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverbindcontext
import * as Hapi from 'hapi';
import * as Hapi from '../../';
interface HandlerThis {
message: string;
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servercacheoptions
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverconnectionoptions
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
const web = server.connection({ port: 8000, host: 'example.com', labels: ['web'] });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverconnections
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var server = new Hapi.Server();
server.connection({ port: 80, labels: 'a' });
server.connection({ port: 8080, labels: 'b' });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder
import * as Hapi from 'hapi';
import * as Hapi from '../../';
import * as Zlib from 'zlib';
const server = new Hapi.Server();
server.connection({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -12,7 +12,7 @@ const success = function (this: Hapi.ReplyNoContinue) {
server.decorate('reply', 'success', success);
declare module 'hapi' {
declare module '../../' {
interface Base_Reply {
success: () => Response;
}
@@ -36,7 +36,7 @@ server.decorate('request', 'some_request_method', (request) => {
}
}, {apply: true});
declare module 'hapi' {
declare module '../../' {
interface Request {
some_request_method(): void;
}
@@ -59,7 +59,7 @@ server.decorate('server', 'some_server_method', (server: Hapi.Server) => {
}
});
declare module 'hapi' {
declare module '../../' {
interface Server {
some_server_method(arg1: number): string;
}
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverdependencydependencies-after
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const after: Hapi.AfterDependencyLoadCallback = function (server, next) {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverencoderencoding-encoder
import * as Hapi from 'hapi';
import * as Hapi from '../../';
import * as Zlib from 'zlib';
const server = new Hapi.Server();
server.connection({ port: 80, routes: { compression: { special: { chunkSize: 16 * 1024 } } } });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servereventevents
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverexposekey-value
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var register: Hapi.PluginFunction<{}> = function (server, options, next) {
server.expose('util', function () { console.log('something'); });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverextevents
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverhandlername-method
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ host: 'localhost', port: 8000 });
@@ -20,7 +20,7 @@ interface TestPluginConfig {
msg: string;
}
declare module 'hapi' {
declare module '../../' {
interface RouteHandlerPlugins {
test?: TestPluginConfig;
}
@@ -2,7 +2,7 @@
// From https://hapijs.com/api/16.1.1#serverinfo
import assert = require('assert');
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
var options: Hapi.ServerConnectionOptions = { port: 80 };
server.connection(options);
@@ -1,8 +1,8 @@
// From https://hapijs.com/api/16.1.1#serverinitializecallback
import * as Hapi from 'hapi';
const Hoek = require('hoek');
import * as Hapi from '../../';
const Hoek = require('../../../../hoek');
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverinjectoptions-callback
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverlistener
import * as Hapi from 'hapi';
import * as Hapi from '../../';
import SocketIO = require('socket.io');
const server = new Hapi.Server();
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverload
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server({ load: { sampleInterval: 1000 } });
var d: number = server.load.rss;
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverlookupid
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection();
server.route({
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servermatchmethod-path-host
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection();
server.route({
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servermethodname-method-options
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servermethods
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
const add = function (a: number, b: number, next: (err: Error | null, result: number) => void) {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servermime
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const options: Hapi.ServerOptions = {
mime: {
@@ -1,6 +1,6 @@
'use strict';
import * as Hapi from 'hapi';
import * as Hapi from '../../';
new Hapi.Server();
new Hapi.Server({
@@ -45,7 +45,7 @@ new Hapi.Server({
});
//+ Code added in addition to docs
declare module 'hapi' {
declare module '../../' {
interface PluginSpecificConfiguration {
// Set this to non optional if plugin config is non optional
'some-plugin-name'?: {options: string;};
@@ -2,7 +2,7 @@
// From https://hapijs.com/api/16.1.1#serveroncriteria-listener
// From https://hapijs.com/api/16.1.1#server-events
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serveroncecriteria-listener
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverpathrelativeto
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var register: Hapi.PluginFunction<{}> = function (server, options, next) {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverplugins
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverrealm
import * as Hapi from 'hapi';
import * as Hapi from '../../';
var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) {
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverrouteoptions
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverselectlabels
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80, labels: ['a', 'b'] });
server.connection({ port: 8080, labels: ['a', 'c'] });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serversettings
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server({
app: {
key: 'value'
@@ -1,8 +1,8 @@
// From https://hapijs.com/api/16.1.1#serverstartcallback
import * as Hapi from 'hapi';
import * as Hoek from 'hoek';
import * as Hapi from '../../';
import * as Hoek from '../../../../hoek';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverstatename-options
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#serverstopoptions-callback
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80 });
@@ -1,7 +1,7 @@
// From https://hapijs.com/api/16.1.1#servertablehost
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.connection({ port: 80, host: 'example.com' });
server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } });
@@ -1,6 +1,6 @@
// From http://hapijs.com/api#serversettings
import * as Hapi from 'hapi';
import * as Hapi from '../../';
const server = new Hapi.Server();
server.version === '8.0.0'
+102
View File
@@ -0,0 +1,102 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": false,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"hapi": [
"hapi/v16"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"test/connection/table.ts",
"test/continuation/errors.ts",
"test/getting-started/01-creating-a-server.ts",
"test/getting-started/02-adding-routes.ts",
"test/getting-started/03-serving-static-content.ts",
"test/getting-started/04-using-plugins.ts",
"test/path/catch-all.ts",
"test/path/parameters.ts",
"test/plugins/options.ts",
"test/reply/continue.ts",
"test/reply/entity.ts",
"test/reply/redirect.ts",
"test/reply/reply.ts",
"test/reply/state_cookie.ts",
"test/request/event-types.ts",
"test/request/generate-response.ts",
"test/request/get-log.ts",
"test/request/log.ts",
"test/request/query.ts",
"test/request/set-method.ts",
"test/request/set-url.ts",
"test/request/tail.ts",
"test/response/error-representation.ts",
"test/response/error.ts",
"test/response/events.ts",
"test/response/flow-control.ts",
"test/route/additional-options.ts",
"test/route/auth.ts",
"test/route/config.ts",
"test/route/handler.ts",
"test/route/plugins.ts",
"test/route/prerequisites.ts",
"test/route/public-interface.ts",
"test/route/validate.ts",
"test/server/app.ts",
"test/server/auth.ts",
"test/server/bind.ts",
"test/server/cache.ts",
"test/server/connection-options.ts",
"test/server/connections.ts",
"test/server/decoder.ts",
"test/server/decorate.ts",
"test/server/dependency.ts",
"test/server/emit.ts",
"test/server/encoder.ts",
"test/server/event.ts",
"test/server/expose.ts",
"test/server/ext.ts",
"test/server/handler.ts",
"test/server/info.ts",
"test/server/initialize.ts",
"test/server/inject.ts",
"test/server/listener.ts",
"test/server/load.ts",
"test/server/log.ts",
"test/server/lookup.ts",
"test/server/match.ts",
"test/server/method.ts",
"test/server/methods.ts",
"test/server/mime.ts",
"test/server/new.ts",
"test/server/on.ts",
"test/server/once.ts",
"test/server/path.ts",
"test/server/plugins.ts",
"test/server/realm.ts",
"test/server/register.ts",
"test/server/route.ts",
"test/server/select.ts",
"test/server/settings.ts",
"test/server/start.ts",
"test/server/state.ts",
"test/server/stop.ts",
"test/server/table.ts",
"test/server/version.ts"
]
}