-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
index.d.ts
86 lines (73 loc) · 1.97 KB
/
index.d.ts
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/// <reference types="node" />
import { EventEmitter } from 'events';
import * as grpc from '@grpc/grpc-js';
type GrpcRequest = any;
type GrpcResponse = any;
type GrpcCall =
grpc.ServerUnaryCall<any, any> |
grpc.ServerReadableStream<any, any> |
grpc.ServerWritableStream<any, any> |
grpc.ServerDuplexStream<any, any>
interface App<T> {
context: T
}
declare class Mali<T> extends EventEmitter implements App<T> {
constructor(path?: any, name?: string | ReadonlyArray<string>, options?: any);
name: string;
env: string;
ports: ReadonlyArray<number>;
silent: boolean;
context: T
addService (path: any, name?: string | ReadonlyArray<string>, options?: any): void;
use (service?: any, name?: any, fns?: any): void;
start (port: number | string, creds?: any, options?: any): Promise<grpc.Server>;
toJSON (): any;
close (): Promise<void>;
inspect (): any;
}
declare namespace Mali {
interface Context<R> {
name: string;
fullName: string;
service: string;
package: string;
app: App<R>;
call: GrpcCall;
request: Request;
response: Response;
req: GrpcRequest;
res: GrpcResponse;
type: string;
metadata: any;
locals: Record<string, any>;
get (field: string): any;
set (field: any, val?: any): void;
sendMetadata (md: any): void;
getStatus (field: string): any;
setStatus (field: any, val?: any): void;
}
class Request {
constructor(call: any, type: string);
call: any;
type: string;
metadata: any;
req: GrpcRequest;
getMetadata (): grpc.Metadata;
get (field: string): any;
}
class Response {
constructor(call: any, type: string);
call: any;
type: string;
metadata: any;
status: any;
res: GrpcResponse;
set (field: any, val?: any): void;
get (field: string): any;
getMetadata (): grpc.Metadata;
sendMetadata (md?: any): void;
getStatus (field: string): any;
setStatus (field: any, val?: any): void;
}
}
export = Mali;