nxkit
Version:
This is a collection of tools, independent of any other libraries
105 lines (104 loc) • 2.28 kB
TypeScript
/// <reference types="node" />
import * as http from 'http';
import * as net from 'net';
import { Server } from './_server';
import { RuleResult } from './router';
/**
* base service abstract class
* @class Service
*/
export declare class Service {
private m_pathname;
private m_dirname;
private m_extname;
private m_params;
private m_headers;
static type: string;
/**
* @type {String} 服务名称
*/
readonly name: string;
/**
* server
* @type {Server}
*/
readonly server: Server;
/**
* request of server
* @type {http.ServerRequest}
*/
readonly request: http.IncomingMessage;
/**
* @type {net.Stream}
*/
readonly socket: net.Socket;
/**
* request host
* @type {String}
*/
readonly host: string;
/**
* request path
* @type {String}
*/
readonly url: string;
/**
* no param url
* @type {String}
*/
get pathname(): string;
/**
* request path directory
* @type {String}
*/
get dirname(): string;
/**
* request extended name
* @type {String}
*/
get extname(): string;
/**
* url param list
* @type {Object}
*/
get params(): Dict<any>;
get headers(): http.IncomingHttpHeaders;
/**
* @func setTimeout(value)
*/
setTimeout(value: number): void;
/**
* @constructor
* @arg req {http.ServerRequest}
*/
constructor(req: http.IncomingMessage);
/**
* authentication by default all, subclasses override
* @param {Function} cb
* @param {Object} info
*/
requestAuth(info: RuleResult): Promise<boolean> | boolean;
/**
* call function virtual function
* @param {Object} info service info
*/
action(info: RuleResult): void;
}
declare const _default: {
Service: typeof Service;
/**
* 获取所有的服务名称列表
*/
readonly services: string[];
/**
* 通过名称获取服务class
*/
get(name: string): typeof Service;
/**
* @func getServiceDescriptors()
*/
getServiceDescriptors(): Dict<any>;
set(name: string, cls: any): void;
del(name: string): void;
};
export default _default;