-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
97 lines (80 loc) · 1.65 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
87
88
89
90
91
92
93
94
95
96
97
import * as Koa from 'koa';
import { Logger, Layout } from 'log4js';
import * as KoaRouter from 'koa-router';
declare module Owl {
export class BaseContextClass {
/**
* request context
*/
ctx: Koa.Context;
/**
* Application
*/
app: OwlApplcation;
/**
* service
*/
service: Service;
/**
* model
*/
model: Model;
constructor(ctx: Koa.Context);
}
export class Controller extends BaseContextClass {}
export class Service extends BaseContextClass { }
export class Model extends BaseContextClass {
/**
*
* @param key name
* @param cb callback
*/
static caches(key: string, cb: Function): Object;
}
/**
* logconfig
*/
export interface ILogConfig {
logFilePath: string;
layout?: Layout;
pattern?: string;
pm2?: boolean;
filterHeaders?: Array<string>;
}
/**
* fetch config
*/
export interface IFetchConfig {
url: string;
method?: string;
data?: any;
headers?: any;
timeout?: number;
}
export interface IContext extends Koa.Context {
readonly clientIP: string;
readonly serverIp: string;
readonly requestId: string;
json(data: Object);
fetch(config: IFetchConfig): Promise;
}
/**
* owlconfig
*/
export interface IOwlConfig {
pkg: string;
rootPath: string;
viewRoot: string;
PORT: number;
logConfig: ILogConfig;
fetchTimeout?: number;
apiTraceKey?: string;
}
export class OwlApplcation extends Koa {
constructor(config: IOwlConfig);
readonly logger: Logger;
bootstrap(cb?:Function);
router: KoaRouter;
}
}
export = Owl;