hapii-js 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,152 @@
1
+ import { Server, ServerApplicationState } from './server';
2
+ import { ReqRef, ReqRefDefaults } from '../request';
3
+ import { Lifecycle } from '../utils';
4
+
5
+ /**
6
+ * The extension point event name. The available extension points include the request extension points as well as the following server extension points:
7
+ * 'onPreStart' - called before the connection listeners are started.
8
+ * 'onPostStart' - called after the connection listeners are started.
9
+ * 'onPreStop' - called before the connection listeners are stopped.
10
+ * 'onPostStop' - called after the connection listeners are stopped.
11
+ * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents)
12
+ * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle)
13
+ */
14
+ export type ServerExtType = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop';
15
+ export type RouteRequestExtType = 'onPreAuth'
16
+ | 'onCredentials'
17
+ | 'onPostAuth'
18
+ | 'onPreHandler'
19
+ | 'onPostHandler'
20
+ | 'onPreResponse'
21
+ | 'onPostResponse';
22
+
23
+ export type ServerRequestExtType =
24
+ RouteRequestExtType
25
+ | 'onRequest';
26
+
27
+ /**
28
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents)
29
+ * Registers an extension function in one of the request lifecycle extension points where:
30
+ * @param events - an object or array of objects with the following:
31
+ * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points:
32
+ * * * 'onPreStart' - called before the connection listeners are started.
33
+ * * * 'onPostStart' - called after the connection listeners are started.
34
+ * * * 'onPreStop' - called before the connection listeners are stopped.
35
+ * * * 'onPostStop' - called after the connection listeners are stopped.
36
+ * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is:
37
+ * * * server extension points: async function(server) where:
38
+ * * * * server - the server object.
39
+ * * * * this - the object provided via options.bind or the current active context set with server.bind().
40
+ * * * request extension points: a lifecycle method.
41
+ * * options - (optional) an object with the following:
42
+ * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added.
43
+ * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added.
44
+ * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function.
45
+ * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or
46
+ * when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to.
47
+ * @return void
48
+ */
49
+ export interface ServerExtEventsObject<A = ServerApplicationState> {
50
+ /**
51
+ * (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points:
52
+ * * 'onPreStart' - called before the connection listeners are started.
53
+ * * 'onPostStart' - called after the connection listeners are started.
54
+ * * 'onPreStop' - called before the connection listeners are stopped.
55
+ */
56
+ type: ServerExtType;
57
+ /**
58
+ * (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is:
59
+ * * server extension points: async function(server) where:
60
+ * * * server - the server object.
61
+ * * * this - the object provided via options.bind or the current active context set with server.bind().
62
+ * * request extension points: a lifecycle method.
63
+ */
64
+ method: ServerExtPointFunction<A> | ServerExtPointFunction<A>[];
65
+ options?: ServerExtOptions | undefined;
66
+ }
67
+
68
+ export interface RouteExtObject<Refs extends ReqRef = ReqRefDefaults> {
69
+ method: Lifecycle.Method<Refs>;
70
+ options?: ServerExtOptions | undefined;
71
+ }
72
+
73
+ /**
74
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents)
75
+ * Registers an extension function in one of the request lifecycle extension points where:
76
+ * @param events - an object or array of objects with the following:
77
+ * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points:
78
+ * * * 'onPreStart' - called before the connection listeners are started.
79
+ * * * 'onPostStart' - called after the connection listeners are started.
80
+ * * * 'onPreStop' - called before the connection listeners are stopped.
81
+ * * * 'onPostStop' - called after the connection listeners are stopped.
82
+ * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is:
83
+ * * * server extension points: async function(server) where:
84
+ * * * * server - the server object.
85
+ * * * * this - the object provided via options.bind or the current active context set with server.bind().
86
+ * * * request extension points: a lifecycle method.
87
+ * * options - (optional) an object with the following:
88
+ * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added.
89
+ * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added.
90
+ * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function.
91
+ * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or
92
+ * when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to.
93
+ * @return void
94
+ */
95
+ export interface ServerExtEventsRequestObject {
96
+ /**
97
+ * (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points:
98
+ * * 'onPreStart' - called before the connection listeners are started.
99
+ * * 'onPostStart' - called after the connection listeners are started.
100
+ * * 'onPreStop' - called before the connection listeners are stopped.
101
+ * * 'onPostStop' - called after the connection listeners are stopped.
102
+ */
103
+ type: ServerRequestExtType;
104
+ /**
105
+ * (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is:
106
+ * * server extension points: async function(server) where:
107
+ * * * server - the server object.
108
+ * * * this - the object provided via options.bind or the current active context set with server.bind().
109
+ * * request extension points: a lifecycle method.
110
+ */
111
+ method: Lifecycle.Method | Lifecycle.Method[];
112
+ /**
113
+ * (optional) an object with the following:
114
+ * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added.
115
+ * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added.
116
+ * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function.
117
+ * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions,
118
+ * or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to.
119
+ */
120
+ options?: ServerExtOptions | undefined;
121
+ }
122
+
123
+ export type ServerExtPointFunction<A = ServerApplicationState> = (server: Server<A>) => void;
124
+
125
+ /**
126
+ * An object with the following:
127
+ * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added.
128
+ * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added.
129
+ * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function.
130
+ * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or
131
+ * when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. For context [See
132
+ * docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents)
133
+ */
134
+ export interface ServerExtOptions {
135
+ /**
136
+ * a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added.
137
+ */
138
+ before?: string | string[] | undefined;
139
+ /**
140
+ * a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added.
141
+ */
142
+ after?: string | string[] | undefined;
143
+ /**
144
+ * a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function.
145
+ */
146
+ bind?: object | undefined;
147
+ /**
148
+ * if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when
149
+ * adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to.
150
+ */
151
+ sandbox?: 'server' | 'plugin' | undefined;
152
+ }
@@ -0,0 +1,11 @@
1
+ export * from './auth';
2
+ export * from './cache';
3
+ export * from './encoders';
4
+ export * from './events';
5
+ export * from './ext';
6
+ export * from './info';
7
+ export * from './inject';
8
+ export * from './methods';
9
+ export * from './options';
10
+ export * from './server';
11
+ export * from './state';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo)
3
+ * An object containing information about the server where:
4
+ */
5
+ export interface ServerInfo {
6
+ /**
7
+ * a unique server identifier (using the format '{hostname}:{pid}:{now base36}').
8
+ */
9
+ id: string;
10
+
11
+ /**
12
+ * server creation timestamp.
13
+ */
14
+ created: number;
15
+
16
+ /**
17
+ * server start timestamp (0 when stopped).
18
+ */
19
+ started: number;
20
+
21
+ /**
22
+ * the connection [port](https://github.com/hapijs/hapi/blob/master/API.md#server.options.port) based on the following rules:
23
+ * * before the server has been started: the configured port value.
24
+ * * after the server has been started: the actual port assigned when no port is configured or was set to 0.
25
+ */
26
+ port: number | string;
27
+
28
+ /**
29
+ * The [host](https://github.com/hapijs/hapi/blob/master/API.md#server.options.host) configuration value.
30
+ */
31
+ host: string;
32
+
33
+ /**
34
+ * the active IP address the connection was bound to after starting. Set to undefined until the server has been
35
+ * started or when using a non TCP port (e.g. UNIX domain socket).
36
+ */
37
+ address: undefined | string;
38
+
39
+ /**
40
+ * the protocol used:
41
+ * * 'http' - HTTP.
42
+ * * 'https' - HTTPS.
43
+ * * 'socket' - UNIX domain socket or Windows named pipe.
44
+ */
45
+ protocol: 'http' | 'https' | 'socket';
46
+
47
+ /**
48
+ * a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains
49
+ * the uri value if set, otherwise constructed from the available settings. If no port is configured or is set
50
+ * to 0, the uri will not include a port component until the server is started.
51
+ */
52
+ uri: string;
53
+ }
@@ -0,0 +1,89 @@
1
+ import { RequestOptions as ShotRequestOptions, ResponseObject as ShotResponseObject } from '@hapi/shot';
2
+ import { PluginsStates } from '../plugin';
3
+ import { AuthArtifacts, AuthCredentials, Request, RequestApplicationState } from '../request';
4
+
5
+ /**
6
+ * An object with:
7
+ * * method - (optional) the request HTTP method (e.g. 'POST'). Defaults to 'GET'.
8
+ * * url - (required) the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers.
9
+ * * headers - (optional) an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default shot headers.
10
+ * * payload - (optional) an string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload
11
+ * processing defaults to 'application/json' if no 'Content-Type' header provided.
12
+ * * credentials - (optional) an credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if
13
+ * they were received via an authentication scheme. Defaults to no credentials.
14
+ * * artifacts - (optional) an artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as
15
+ * if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts.
16
+ * * app - (optional) sets the initial value of request.app, defaults to {}.
17
+ * * plugins - (optional) sets the initial value of request.plugins, defaults to {}.
18
+ * * allowInternals - (optional) allows access to routes with config.isInternal set to true. Defaults to false.
19
+ * * remoteAddress - (optional) sets the remote address for the incoming connection.
20
+ * * simulate - (optional) an object with options used to simulate client request stream conditions for testing:
21
+ * * error - if true, emits an 'error' event after payload transmission (if any). Defaults to false.
22
+ * * close - if true, emits a 'close' event after payload transmission (if any). Defaults to false.
23
+ * * end - if false, does not end the stream. Defaults to true.
24
+ * * split - indicates whether the request payload will be split into chunks. Defaults to undefined, meaning payload will not be chunked.
25
+ * * validate - (optional) if false, the options inputs are not validated. This is recommended for run-time usage of inject() to make it perform faster where input validation can be tested
26
+ * separately.
27
+ * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions)
28
+ * For context [Shot module](https://github.com/hapijs/shot)
29
+ */
30
+ export interface ServerInjectOptions extends ShotRequestOptions {
31
+ /**
32
+ * Authentication bypass options.
33
+ */
34
+ auth?: {
35
+ /**
36
+ * The authentication strategy name matching the provided credentials.
37
+ */
38
+ strategy: string;
39
+ /**
40
+ * The credentials are used to bypass the default authentication strategies,
41
+ * and are validated directly as if they were received via an authentication scheme.
42
+ */
43
+ credentials: AuthCredentials;
44
+ /**
45
+ * The artifacts are used to bypass the default authentication strategies,
46
+ * and are validated directly as if they were received via an authentication scheme. Defaults to no artifacts.
47
+ */
48
+ artifacts?: AuthArtifacts | undefined;
49
+ } | undefined;
50
+ /**
51
+ * sets the initial value of request.app, defaults to {}.
52
+ */
53
+ app?: RequestApplicationState | undefined;
54
+ /**
55
+ * sets the initial value of request.plugins, defaults to {}.
56
+ */
57
+ plugins?: PluginsStates | undefined;
58
+ /**
59
+ * allows access to routes with config.isInternal set to true. Defaults to false.
60
+ */
61
+ allowInternals?: boolean | undefined;
62
+ }
63
+
64
+ /**
65
+ * A response object with the following properties:
66
+ * * statusCode - the HTTP status code.
67
+ * * headers - an object containing the headers set.
68
+ * * payload - the response payload string.
69
+ * * rawPayload - the raw response payload buffer.
70
+ * * raw - an object with the injection request and response objects:
71
+ * * req - the simulated node request object.
72
+ * * res - the simulated node response object.
73
+ * * result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of
74
+ * the internal objects returned (instead of parsing the response string).
75
+ * * request - the request object.
76
+ * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions)
77
+ * For context [Shot module](https://github.com/hapijs/shot)
78
+ */
79
+ export interface ServerInjectResponse<Result = object> extends ShotResponseObject {
80
+ /**
81
+ * the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the
82
+ * internal objects returned (instead of parsing the response string).
83
+ */
84
+ result: Result | undefined;
85
+ /**
86
+ * the request object.
87
+ */
88
+ request: Request;
89
+ }
@@ -0,0 +1,95 @@
1
+ import { CacheStatisticsObject, PolicyOptions } from "@hapi/catbox";
2
+
3
+ type AnyMethod = (...args: any[]) => any;
4
+
5
+ export type CachedServerMethod<T extends AnyMethod> = T & {
6
+ cache?: {
7
+ drop(...args: Parameters<T>): Promise<void>;
8
+ stats: CacheStatisticsObject
9
+ }
10
+ };
11
+
12
+ /**
13
+ * The method function with a signature async function(...args, [flags]) where:
14
+ * * ...args - the method function arguments (can be any number of arguments or none).
15
+ * * flags - when caching is enabled, an object used to set optional method result flags:
16
+ * * * ttl - 0 if result is valid but cannot be cached. Defaults to cache policy.
17
+ * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options)
18
+ */
19
+ export type ServerMethod = AnyMethod;
20
+
21
+ /**
22
+ * The same cache configuration used in server.cache().
23
+ * The generateTimeout option is required.
24
+ * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options)
25
+ * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions)
26
+ */
27
+ export interface ServerMethodCache extends PolicyOptions<any> {
28
+ generateTimeout: number | false;
29
+ cache?: string;
30
+ segment?: string;
31
+ }
32
+
33
+ /**
34
+ * Configuration object:
35
+ * * bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an
36
+ * arrow function.
37
+ * * cache - the same cache configuration used in server.cache(). The generateTimeout option is required.
38
+ * * generateKey - a function used to generate a unique key (for caching) from the arguments passed to the method function (the flags argument is not passed as input). The server will automatically
39
+ * generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided
40
+ * which takes the same arguments as the function and returns a unique string (or null if no key can be generated). For reference [See
41
+ * docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options)
42
+ */
43
+ export interface ServerMethodOptions {
44
+ /**
45
+ * a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow
46
+ * function.
47
+ */
48
+ bind?: object | undefined;
49
+ /**
50
+ * the same cache configuration used in server.cache(). The generateTimeout option is required.
51
+ */
52
+ cache?: ServerMethodCache | undefined;
53
+ /**
54
+ * a function used to generate a unique key (for caching) from the arguments passed to the method function (the flags argument is not passed as input). The server will automatically generate a
55
+ * unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which
56
+ * takes the same arguments as the function and returns a unique string (or null if no key can be generated).
57
+ */
58
+ generateKey?(...args: any[]): string | null;
59
+ }
60
+
61
+ /**
62
+ * An object or an array of objects where each one contains:
63
+ * * name - the method name.
64
+ * * method - the method function.
65
+ * * options - (optional) settings.
66
+ * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods)
67
+ */
68
+ export interface ServerMethodConfigurationObject {
69
+ /**
70
+ * the method name.
71
+ */
72
+ name: string;
73
+ /**
74
+ * the method function.
75
+ */
76
+ method: ServerMethod;
77
+ /**
78
+ * (optional) settings.
79
+ */
80
+ options?: ServerMethodOptions | undefined;
81
+ }
82
+
83
+ interface BaseServerMethods {
84
+ [name: string]: (
85
+ ServerMethod |
86
+ CachedServerMethod<ServerMethod> |
87
+ BaseServerMethods
88
+ );
89
+ }
90
+
91
+ /**
92
+ * An empty interface to allow typings of custom server.methods.
93
+ */
94
+ export interface ServerMethods extends BaseServerMethods {
95
+ }
@@ -0,0 +1,235 @@
1
+ import * as http from 'http';
2
+ import * as https from 'https';
3
+
4
+ import { MimosOptions } from '@hapi/mimos';
5
+
6
+ import { PluginSpecificConfiguration } from '../plugin';
7
+ import { RouteOptions } from '../route';
8
+ import { CacheProvider, ServerOptionsCache } from './cache';
9
+ import { SameSitePolicy, ServerStateCookieOptions } from './state';
10
+
11
+ export interface ServerOptionsCompression {
12
+ minBytes: number;
13
+ }
14
+
15
+ /**
16
+ * Empty interface to allow for custom augmentation.
17
+ */
18
+
19
+ export interface ServerOptionsApp {
20
+ }
21
+
22
+ /**
23
+ * The server options control the behavior of the server object. Note that the options object is deeply cloned
24
+ * (with the exception of listener which is shallowly copied) and should not contain any values that are unsafe to perform deep copy on.
25
+ * All options are optionals.
26
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-server-options)
27
+ */
28
+ export interface ServerOptions {
29
+ /**
30
+ * @default '0.0.0.0' (all available network interfaces).
31
+ * Sets the hostname or IP address the server will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces. Set to '127.0.0.1' or 'localhost' to
32
+ * restrict the server to only those coming from the same host.
33
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsaddress)
34
+ */
35
+ address?: string | undefined;
36
+
37
+ /**
38
+ * @default {}.
39
+ * Provides application-specific configuration which can later be accessed via server.settings.app. The framework does not interact with this object. It is simply a reference made available
40
+ * anywhere a server reference is provided. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time
41
+ * state.
42
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsapp)
43
+ */
44
+ app?: ServerOptionsApp | undefined;
45
+
46
+ /**
47
+ * @default true.
48
+ * Used to disable the automatic initialization of the listener. When false, indicates that the listener will be started manually outside the framework.
49
+ * Cannot be set to true along with a port value.
50
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsautolisten)
51
+ */
52
+ autoListen?: boolean | undefined;
53
+
54
+ /**
55
+ * @default { engine: require('@hapi/catbox-memory' }.
56
+ * Sets up server-side caching providers. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and
57
+ * capabilities. hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized
58
+ * if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. The configuration can be assigned one or more
59
+ * (array):
60
+ * * a class or prototype function (usually obtained by calling require() on a catbox strategy such as require('@hapi/catbox-redis')). A new catbox client will be created internally using this
61
+ * function.
62
+ * * a configuration object with the following:
63
+ * * * engine - a class, a prototype function, or a catbox engine object.
64
+ * * * name - an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines
65
+ * the default cache. If every cache includes a name, a default memory cache is provisioned as well.
66
+ * * * shared - if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false.
67
+ * * * partition - (optional) string used to isolate cached data. Defaults to 'hapi-cache'.
68
+ * * * other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object).
69
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionscache)
70
+ */
71
+ cache?: CacheProvider | ServerOptionsCache | ServerOptionsCache[] | undefined;
72
+
73
+ /**
74
+ * @default { minBytes: 1024 }.
75
+ * Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server.
76
+ */
77
+ compression?: boolean | ServerOptionsCompression | undefined;
78
+
79
+ /**
80
+ * @default { request: ['implementation'] }.
81
+ * Determines which logged events are sent to the console. This should only be used for development and does not affect which events are actually logged internally and recorded. Set to false to
82
+ * disable all console logging, or to an object with:
83
+ * * log - a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. Defaults to no output.
84
+ * * request - a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to
85
+ * display all errors, set the option to ['error']. To turn off all console debug messages set it to false. To display all request logs, set it to '*'. Defaults to uncaught errors thrown in
86
+ * external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. For example, to display all errors, set the log
87
+ * or request to ['error']. To turn off all output set the log or request to false. To display all server logs, set the log or request to '*'. To disable all debug information, set debug to
88
+ * false.
89
+ */
90
+ debug?: false | {
91
+ log?: string | string[] | false | undefined;
92
+ request?: string | string[] | false | undefined;
93
+ } | undefined;
94
+
95
+ /**
96
+ * @default the operating system hostname and if not available, to 'localhost'.
97
+ * The public hostname or IP address. Used to set server.info.host and server.info.uri and as address is none provided.
98
+ */
99
+ host?: string | undefined;
100
+
101
+ info?: {
102
+ /**
103
+ * @default false.
104
+ * If true, the request.info.remoteAddress and request.info.remotePort are populated when the request is received which can consume more resource (but is ok if the information is needed,
105
+ * especially for aborted requests). When false, the fields are only populated upon demand (but will be undefined if accessed after the request is aborted).
106
+ */
107
+ remote?: boolean | undefined;
108
+ } | undefined;
109
+
110
+ /**
111
+ * @default none.
112
+ * An optional node HTTP (or HTTPS) http.Server object (or an object with a compatible interface).
113
+ * If the listener needs to be manually started, set autoListen to false.
114
+ * If the listener uses TLS, set tls to true.
115
+ */
116
+ listener?: http.Server | undefined;
117
+
118
+ /**
119
+ * @default { sampleInterval: 0 }.
120
+ * Server excessive load handling limits where:
121
+ * * sampleInterval - the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling).
122
+ * * maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
123
+ * * maxRssBytes - maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
124
+ * * maxEventLoopDelay - maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
125
+ */
126
+ load?: {
127
+ /** the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). */
128
+ sampleInterval?: number | undefined;
129
+
130
+ /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */
131
+ maxHeapUsedBytes?: number | undefined;
132
+ /**
133
+ * maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).
134
+ */
135
+ maxRssBytes?: number | undefined;
136
+ /**
137
+ * maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response.
138
+ * Defaults to 0 (no limit).
139
+ */
140
+ maxEventLoopDelay?: number | undefined;
141
+ } | undefined;
142
+
143
+ /**
144
+ * @default none.
145
+ * Options passed to the mimos module when generating the mime database used by the server (and accessed via server.mime):
146
+ * * override - an object hash that is merged into the built in mime information specified here. Each key value pair represents a single mime object. Each override value must contain:
147
+ * * key - the lower-cased mime-type string (e.g. 'application/javascript').
148
+ * * value - an object following the specifications outlined here. Additional values include:
149
+ * * * type - specify the type value of result objects, defaults to key.
150
+ * * * predicate - method with signature function(mime) when this mime type is found in the database, this function will execute to allows customizations.
151
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsmime)
152
+ */
153
+ mime?: MimosOptions | undefined;
154
+
155
+ /**
156
+ * @default { cleanStop: true }
157
+ * Defines server handling of server operations.
158
+ */
159
+ operations?: {
160
+ /**
161
+ * @default true
162
+ * If true, the server keeps track of open connections and properly closes them when the server is stopped.
163
+ * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsoperations)
164
+ */
165
+ cleanStop?: boolean;
166
+ }
167
+
168
+ /**
169
+ * @default {}.
170
+ * Plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the
171
+ * difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state.
172
+ */
173
+ plugins?: PluginSpecificConfiguration | undefined;
174
+
175
+ /**
176
+ * @default 0 (an ephemeral port).
177
+ * The TCP port the server will listen to. Defaults the next available port when the server is started (and assigned to server.info.port).
178
+ * If port is a string containing a '/' character, it is used as a UNIX domain socket path. If it starts with '\.\pipe', it is used as a Windows named pipe.
179
+ */
180
+ port?: number | string | undefined;
181
+
182
+ /**
183
+ * @default { isCaseSensitive: true, stripTrailingSlash: false }.
184
+ * Controls how incoming request URIs are matched against the routing table:
185
+ * * isCaseSensitive - determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true.
186
+ * * stripTrailingSlash - removes trailing slashes on incoming paths. Defaults to false.
187
+ */
188
+ router?: {
189
+ isCaseSensitive?: boolean | undefined;
190
+ stripTrailingSlash?: boolean | undefined;
191
+ } | undefined;
192
+
193
+ /**
194
+ * @default none.
195
+ * A route options object used as the default configuration for every route.
196
+ */
197
+ routes?: RouteOptions | undefined;
198
+
199
+ /**
200
+ * Default value:
201
+ * {
202
+ * strictHeader: true,
203
+ * ignoreErrors: false,
204
+ * isSecure: true,
205
+ * isHttpOnly: true,
206
+ * isSameSite: 'Strict',
207
+ * encoding: 'none'
208
+ * }
209
+ * Sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the state configuration object.
210
+ */
211
+ state?: ServerStateCookieOptions | undefined;
212
+
213
+ /**
214
+ * @default none.
215
+ * Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation.
216
+ */
217
+ tls?: boolean | https.ServerOptions | undefined;
218
+
219
+ /**
220
+ * @default constructed from runtime server information.
221
+ * The full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the server server.info.uri, otherwise constructed from the server settings.
222
+ */
223
+ uri?: string | undefined;
224
+
225
+ /**
226
+ * Query parameter configuration.
227
+ */
228
+ query?: {
229
+ /**
230
+ * the method must return an object where each key is a parameter and matching value is the parameter value.
231
+ * If the method throws, the error is used as the response or returned when `request.setUrl` is called.
232
+ */
233
+ parser(raw: Record<string, string>): Record<string, any>;
234
+ } | undefined;
235
+ }