1 | import Knex = require('knex');
|
2 | import Koa = require('koa');
|
3 | import Bluebird = require('bluebird');
|
4 |
|
5 | type Upload = {
|
6 | pathname: string,
|
7 | filename: string
|
8 | }
|
9 |
|
10 | declare function PropApi(): Function;
|
11 |
|
12 | declare function PropRpc(): Function;
|
13 |
|
14 | declare function PropAction(props: { auth: boolean, login: boolean }): Function;
|
15 |
|
16 | declare function PropSocket(props: { auth: boolean, login: boolean }): Function;
|
17 |
|
18 |
|
19 | interface JinghuanDb extends Knex.QueryBuilder {
|
20 | sql(sql: string): JinghuanDb
|
21 | }
|
22 |
|
23 | interface JinghuanContext extends Koa.Context {
|
24 | readonly module: string;
|
25 | readonly controller: string;
|
26 | readonly action: string;
|
27 | readonly userAgent: string;
|
28 | readonly isGet: boolean;
|
29 | readonly isPost: boolean;
|
30 | readonly body: any;
|
31 |
|
32 | referer(onlyHost: boolean): string;
|
33 |
|
34 | referrer(onlyHost: boolean): string;
|
35 |
|
36 | isMethod(method: string): boolean;
|
37 |
|
38 | isAjax(method: string): boolean;
|
39 |
|
40 | expires(time: any): any
|
41 |
|
42 | param(): object;
|
43 |
|
44 | param(name: string): object;
|
45 |
|
46 | post(): object;
|
47 |
|
48 | post(value: object): this;
|
49 |
|
50 | file(): object;
|
51 |
|
52 | file(data: object): this;
|
53 |
|
54 | file(name: string): any;
|
55 |
|
56 | file(name: string, value: any): this;
|
57 |
|
58 | download(filepath: string, filename?: string): void;
|
59 |
|
60 | db(table: string): JinghuanDb;
|
61 |
|
62 | db(type: symbol, table: string): JinghuanDb;
|
63 |
|
64 | db<T>(transactionScope: (trx: Knex.Transaction) => Promise<T> | Bluebird<T> | void): Bluebird<T>;
|
65 |
|
66 | sql(name: string): JinghuanDb;
|
67 |
|
68 | sql(type: symbol, name: string): JinghuanDb;
|
69 |
|
70 | upload(file: string, dir: string, filename: string, filter?: Array): Upload
|
71 | }
|
72 |
|
73 | class JinghuanController {
|
74 | readonly ctx: JinghuanContext;
|
75 | readonly userAgent: string;
|
76 | readonly isGet: boolean;
|
77 | readonly isPost: boolean;
|
78 | body: any;
|
79 |
|
80 | referer(onlyHost: boolean): string;
|
81 |
|
82 | referrer(onlyHost: boolean): string;
|
83 |
|
84 | isMethod(method: string): boolean;
|
85 |
|
86 | isAjax(method: string): boolean;
|
87 |
|
88 | expires(time: any): any
|
89 |
|
90 | param(): object;
|
91 |
|
92 | param(name: string): object;
|
93 |
|
94 | post(): object;
|
95 |
|
96 | post(value: object): this;
|
97 |
|
98 | file(): object;
|
99 |
|
100 | file(data: object): this;
|
101 |
|
102 | file(name: string): any;
|
103 |
|
104 | file(name: string, value: any): this;
|
105 |
|
106 | download(filepath: string, filename?: string): void;
|
107 |
|
108 | db(table: string): JinghuanDb;
|
109 |
|
110 | db(type: symbol, table: string): JinghuanDb;
|
111 |
|
112 | db<T>(transactionScope: (trx: Knex.Transaction) => Promise<T> | Bluebird<T> | void): Bluebird<T>;
|
113 |
|
114 | sql(name: string): JinghuanDb;
|
115 |
|
116 | sql(type: symbol, name: string): JinghuanDb;
|
117 |
|
118 | upload(file: string, dir: string, filename: string, filter?: Array): Upload
|
119 | }
|
120 |
|
121 |
|
122 | declare namespace jinghuan {
|
123 | const JH_ROOT: string;
|
124 | const APP_PATH: string;
|
125 | const ROOT_PATH: string;
|
126 | const modules: string[];
|
127 | const modulePaths: object;
|
128 | const mode: string;
|
129 | const source: string;
|
130 | const env: string;
|
131 | const workers: string;
|
132 | const PORT: string;
|
133 | const HOST: string;
|
134 | const paths: string[];
|
135 | const process_id: number;
|
136 | const watcher: boolean;
|
137 | const version: string;
|
138 |
|
139 | interface Controller extends JinghuanController {
|
140 | }
|
141 |
|
142 | const app: Koa;
|
143 | const logger: {
|
144 | log(...args: any[]): void;
|
145 | debug(...args: any[]): void;
|
146 | info(...args: any[]): void;
|
147 | debug(...args: any[]): void;
|
148 | warn(...args: any[]): void;
|
149 | }
|
150 | }
|
151 |
|
152 |
|
153 | declare namespace jinghuanjs {
|
154 | const JH_ROOT: string;
|
155 | const APP_PATH: string;
|
156 | const ROOT_PATH: string;
|
157 | const modules: string[];
|
158 | const modulePaths: object;
|
159 | const mode: string;
|
160 | const source: string;
|
161 | const env: string;
|
162 | const workers: string;
|
163 | const PORT: string;
|
164 | const HOST: string;
|
165 | const paths: string[];
|
166 | const process_id: number;
|
167 | const watcher: boolean;
|
168 | const version: string;
|
169 |
|
170 | interface Controller extends JinghuanController {
|
171 | }
|
172 |
|
173 | const app: Koa;
|
174 | const logger: {
|
175 | log(...args: any[]): void;
|
176 | debug(...args: any[]): void;
|
177 | info(...args: any[]): void;
|
178 | debug(...args: any[]): void;
|
179 | warn(...args: any[]): void;
|
180 | }
|
181 | }
|
182 |
|
183 |
|
184 |
|
185 |
|
\ | No newline at end of file |