mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
More Server Definitions.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents)
|
||||
* Access: podium public interface.
|
||||
* The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters.
|
||||
*/
|
||||
// TODO it needs to be implemented
|
||||
export interface ServerEvents {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo)
|
||||
* An object containing information about the server where:
|
||||
*/
|
||||
export interface ServerInfo {
|
||||
|
||||
/**
|
||||
* a unique server identifier (using the format '{hostname}:{pid}:{now base36}').
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* server creation timestamp.
|
||||
*/
|
||||
created: number;
|
||||
|
||||
/**
|
||||
* server start timestamp (0 when stopped).
|
||||
*/
|
||||
started: number;
|
||||
|
||||
/**
|
||||
* the connection [port](https://github.com/hapijs/hapi/blob/master/API.md#server.options.port) based on the following rules:
|
||||
* * before the server has been started: the configured port value.
|
||||
* * after the server has been started: the actual port assigned when no port is configured or was set to 0.
|
||||
*/
|
||||
port: number | string;
|
||||
|
||||
/**
|
||||
* The [host](https://github.com/hapijs/hapi/blob/master/API.md#server.options.host) configuration value.
|
||||
*/
|
||||
host: string;
|
||||
|
||||
/**
|
||||
* the active IP address the connection was bound to after starting. Set to undefined until the server has been
|
||||
* started or when using a non TCP port (e.g. UNIX domain socket).
|
||||
*/
|
||||
address: undefined | string;
|
||||
|
||||
/**
|
||||
* the protocol used:
|
||||
* * 'http' - HTTP.
|
||||
* * 'https' - HTTPS.
|
||||
* * 'socket' - UNIX domain socket or Windows named pipe.
|
||||
*/
|
||||
protocol: 'http' | 'https' | 'socket';
|
||||
|
||||
/**
|
||||
* a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains
|
||||
* the uri value if set, otherwise constructed from the available settings. If no port is configured or is set
|
||||
* to 0, the uri will not include a port component until the server is started.
|
||||
*/
|
||||
uri: string;
|
||||
|
||||
}
|
||||
+70
-4
@@ -1,12 +1,16 @@
|
||||
import Events = require('events');
|
||||
import {ServerOptions} from "./server-options";
|
||||
import {ServerInfo} from "./server-info";
|
||||
import {Dictionary} from "../util/util";
|
||||
import {Request} from "../request/request";
|
||||
import * as http from "http";
|
||||
import * as events from 'events';
|
||||
|
||||
|
||||
/**
|
||||
* The server object is the main application container. The server manages all incoming requests along with all
|
||||
* the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80).
|
||||
*/
|
||||
export class Server extends Events.EventEmitter {
|
||||
export class Server extends events.EventEmitter {
|
||||
|
||||
/**
|
||||
Creates a new server object where:
|
||||
@@ -28,15 +32,77 @@ export class Server extends Events.EventEmitter {
|
||||
* returned from its implementation function.
|
||||
*/
|
||||
// TODO is that definition right? It's need review. The v16 is very different.
|
||||
auth?: {
|
||||
auth: {
|
||||
api: Dictionary<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access: read only.
|
||||
* Contains the default authentication configuration is a default strategy was set via server.auth.default().
|
||||
* Contains the default authentication configuration is a default strategy was set via [server.auth.default()](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.default()).
|
||||
*/
|
||||
// TODO it needs to be implemented. I didn't understand the description yet.
|
||||
//server.auth.settings.default
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to the decorations already applied to various framework interfaces. The object must not be
|
||||
* modified directly, but only through server.decorate. Contains:
|
||||
* * request - decorations on the request object.
|
||||
* * toolkit - decorations on the response toolkit.
|
||||
* * server - decorations on the server object.
|
||||
*/
|
||||
decorations: {
|
||||
request: Request,
|
||||
toolkit: any, // TODO Request Toolkit (https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) needs to be implemented.
|
||||
server: Server
|
||||
}
|
||||
|
||||
/**
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo)
|
||||
* An object containing information about the server where:
|
||||
* * id - a unique server identifier (using the format '{hostname}:{pid}:{now base36}').
|
||||
* * created - server creation timestamp.
|
||||
* * started - server start timestamp (0 when stopped).
|
||||
* * port - the connection port based on the following rules:
|
||||
* * host - The host configuration value.
|
||||
* * address - the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket).
|
||||
* * protocol - the protocol used:
|
||||
* * 'http' - HTTP.
|
||||
* * 'https' - HTTPS.
|
||||
* * 'socket' - UNIX domain socket or Windows named pipe.
|
||||
* * uri - a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri value if set, otherwise constructed from the available settings. If no port is configured or is set to 0, the uri will not include a port component until the server is started.
|
||||
*/
|
||||
info: ServerInfo;
|
||||
|
||||
/**
|
||||
* Access: read only and listener public interface.
|
||||
* The node HTTP server object.
|
||||
*/
|
||||
listener: http.Server;
|
||||
|
||||
/**
|
||||
* An object containing the process load metrics (when load.sampleInterval is enabled):
|
||||
* * eventLoopDelay - event loop delay milliseconds.
|
||||
* * heapUsed - V8 heap usage.
|
||||
* * rss - RSS memory usage.
|
||||
*/
|
||||
load: {
|
||||
eventLoopDelay: number;
|
||||
heapUsed: number;
|
||||
rss: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods
|
||||
* Server methods are functions registered with the server and used throughout the application as a common utility.
|
||||
* Their advantage is in the ability to configure them to use the built-in cache and share across multiple request
|
||||
* handlers without having to create a common module.
|
||||
* sever.methods is an object which provides access to the methods registered via server.method() where each
|
||||
* server method name is an object property.
|
||||
*/
|
||||
//methods: Dictionary<ServerMethod>;
|
||||
methods: any; // TODO come back here after implements the server.method()
|
||||
|
||||
|
||||
// TODO It"s not finished
|
||||
|
||||
|
||||
Reference in New Issue
Block a user