Merge pull request #24341 from ozum/master

[hapi] Fix: Make server.app non-optional
This commit is contained in:
Arthur Ozga 2018-03-16 14:46:59 -07:00 committed by GitHub
commit 80c15edab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -2586,7 +2586,7 @@ export interface ServerInjectOptions extends Shot.RequestOptions {
/**
* sets the initial value of request.app, defaults to {}.
*/
app?: ApplicationState;
app: ApplicationState;
/**
* sets the initial value of request.plugins, defaults to {}.
*/
@ -3257,7 +3257,7 @@ export class Server extends Podium {
* Initialized with an empty object.
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp)
*/
app?: ApplicationState;
app: ApplicationState;
/**
* Server Auth: properties and methods

View File

@ -6,20 +6,20 @@ const options: ServerOptions = {
};
declare module "hapi" {
// Demonstrate augmenting the application state.
interface ApplicationState {
key?: string;
}
// Demonstrate augmenting the application state.
interface ApplicationState {
key?: string;
}
}
const server = new Server(options);
server.app!.key = 'value2';
server.app.key = 'value2';
const serverRoute: ServerRoute = {
path: '/',
method: 'GET',
handler(request, h) {
return 'key: ' + request.server.app!.key;
return 'key: ' + request.server.app.key;
}
};

View File

@ -6,7 +6,7 @@ const options: ServerOptions = {
};
const server = new Server(options);
server.app!.key = 'value2';
server.app.key = 'value2';
server.route({
path: '/',