-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
68 lines (64 loc) · 2.38 KB
/
types.d.ts
File metadata and controls
68 lines (64 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import express = require("express");
import { NexusFork } from "./src/nexusfork";
declare module nexusfork {
export interface ServiceComm {
emit(event: string, ...args: any[]): void;
emitWithErrorHandler(onerror: (err: Error) => void, event: string, ...args: any[]): void;
off(event: string, cb: (...args: any[]) => void): void;
on(event: string, cb: (...args: any[]) => void): void;
close(): void;
}
export interface ServiceCommRegistry {
open(service: string, cb:(err: Error, comm?: ServiceComm) => void): void;
emitWithErrorHandler(service: string, event: string, onerror: (err: Error) => void, ...args: any[]): void;
emit(service: string, event: string, ...args: any[]): void;
}
export interface IndexCallback {
(err: Error, nexusfork?: NexusFork): void
}
export interface WebRequest extends express.Request {
readonly services: ServiceCommRegistry;
readonly logger: nulllogger.INullLogger;
readonly hostnamematches?: RegExpMatchArray;
}
export interface WebResponse extends express.Response {
sendStatus(code: number): WebResponse;
sendFailure(err?: Error): WebResponse;
}
export interface WebRequestHandler {
(req: WebRequest, res: WebResponse, next?: express.NextFunction): void;
}
export interface WebHandlerImpl {
(config: any, log?: nulllogger.INullLogger): WebRequestHandler;
}
export interface WebHandler {
install: WebHandlerImpl;
preroute: WebHandlerImpl;
route: WebHandlerImpl;
postroute: WebHandlerImpl;
ready: WebHandlerImpl;
[key: string]: WebHandlerImpl;
}
export interface WebHandlerConfig {
handler?: string;
root?: string;
[key: string]: any;
}
export interface ServiceConfig {
service: string;
[key: string]: any;
}
export interface Config {
name: string;
version: number|string;
description?: string;
services?: ServiceConfig[];
hosts?: {[index: string]: string|(WebHandlerConfig|string)[]};
wwwroot?: string;
wwwapp?: string;
}
export interface Addon {
prewebhost?: (host: string, config: (WebHandlerConfig|string)[]) => void,
postwebhost?: (host: string, handlers: WebHandlerConfig[]) => void
}
}