@maiyunnet/kebab 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +14 -0
- package/index.js +1 -1
- package/lib/buffer.d.ts +25 -0
- package/lib/captcha.d.ts +12 -0
- package/lib/captcha.js +2 -2
- package/lib/consistent.d.ts +20 -0
- package/lib/consistent.js +1 -1
- package/lib/core.d.ts +85 -0
- package/lib/core.js +8 -8
- package/lib/crypto.d.ts +47 -0
- package/lib/crypto.js +1 -1
- package/lib/db.d.ts +88 -0
- package/lib/db.js +5 -5
- package/lib/dns.d.ts +75 -0
- package/lib/dns.js +5 -5
- package/lib/fs.d.ts +49 -0
- package/lib/jwt.d.ts +30 -0
- package/lib/jwt.js +4 -4
- package/lib/kv.d.ts +111 -0
- package/lib/kv.js +2 -2
- package/lib/lan.d.ts +10 -0
- package/lib/lan.js +1 -1
- package/lib/net/formdata.d.ts +23 -0
- package/lib/net/formdata.js +2 -2
- package/lib/net/request.d.ts +23 -0
- package/lib/net/request.js +1 -1
- package/lib/net/response.d.ts +14 -0
- package/lib/net.d.ts +65 -0
- package/lib/net.js +4 -4
- package/lib/s3.d.ts +35 -0
- package/lib/s3.js +2 -2
- package/lib/scan.d.ts +31 -0
- package/lib/scan.js +6 -6
- package/lib/session.d.ts +22 -0
- package/lib/session.js +6 -6
- package/lib/sql.d.ts +57 -0
- package/lib/sql.js +3 -3
- package/lib/ssh/sftp.d.ts +40 -0
- package/lib/ssh/sftp.js +2 -2
- package/lib/ssh/shell.d.ts +13 -0
- package/lib/ssh/shell.js +1 -1
- package/lib/ssh.d.ts +24 -0
- package/lib/text.d.ts +40 -0
- package/lib/text.js +1 -1
- package/lib/time.d.ts +22 -0
- package/lib/time.js +1 -1
- package/lib/ws.d.ts +87 -0
- package/lib/ws.js +2 -2
- package/lib/zip.d.ts +40 -0
- package/lib/zip.js +1 -1
- package/lib/zlib.d.ts +25 -0
- package/main.d.ts +1 -0
- package/package.json +3 -3
- package/sys/child.d.ts +1 -0
- package/sys/child.js +6 -6
- package/sys/cmd.d.ts +1 -0
- package/sys/cmd.js +6 -6
- package/sys/ctr.d.ts +96 -0
- package/sys/master.d.ts +1 -0
- package/sys/master.js +8 -8
- package/sys/mod.d.ts +205 -0
- package/sys/mod.js +5 -5
- package/sys/route.d.ts +31 -0
- package/sys/route.js +8 -8
- package/types/index.d.ts +283 -0
- package/www/example/ctr/main.d.ts +4 -0
- package/www/example/ctr/main.js +1 -1
- package/www/example/ctr/middle.d.ts +6 -0
- package/www/example/ctr/middle.js +1 -1
- package/www/example/ctr/test.d.ts +94 -0
- package/www/example/ctr/test.js +21 -21
- package/www/example/mod/test.d.ts +20 -0
- package/www/example/mod/test.js +2 -2
- package/www/example/mod/testdata.d.ts +9 -0
- package/www/example/mod/testdata.js +1 -1
- package/www/example/ws/mproxy.d.ts +4 -0
- package/www/example/ws/mproxy.js +2 -2
- package/www/example/ws/rproxy.d.ts +4 -0
- package/www/example/ws/rproxy.js +2 -2
- package/www/example/ws/test.d.ts +7 -0
- package/www/example/ws/test.js +2 -2
- package/tsconfig.json +0 -27
package/sys/mod.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import * as lSql from '../lib/sql';
|
|
2
|
+
import * as lDb from '../lib/db';
|
|
3
|
+
import * as sCtr from '../sys/ctr';
|
|
4
|
+
import * as types from '../types';
|
|
5
|
+
declare class Rows<T extends Mod> implements types.Rows<T> {
|
|
6
|
+
private readonly _items;
|
|
7
|
+
constructor(initialItems?: T[]);
|
|
8
|
+
get length(): number;
|
|
9
|
+
item(index: number): T;
|
|
10
|
+
toArray(): Array<Record<string, any>>;
|
|
11
|
+
filter(predicate: (value: T, index: number) => boolean): Rows<T>;
|
|
12
|
+
map<TU>(allbackfn: (value: T, index: number) => TU): TU[];
|
|
13
|
+
[Symbol.iterator](): Iterator<T>;
|
|
14
|
+
}
|
|
15
|
+
export default class Mod {
|
|
16
|
+
protected static _$table: string;
|
|
17
|
+
protected static _$primary: string;
|
|
18
|
+
protected static _$key: string;
|
|
19
|
+
protected static _$soft: boolean;
|
|
20
|
+
protected _updates: Record<string, boolean>;
|
|
21
|
+
protected _data: Record<string, any>;
|
|
22
|
+
protected _index: string[] | null;
|
|
23
|
+
protected _contain: {
|
|
24
|
+
'key': string;
|
|
25
|
+
'list': string[];
|
|
26
|
+
} | null;
|
|
27
|
+
protected _total: number[];
|
|
28
|
+
protected _db: lDb.Pool | lDb.Transaction;
|
|
29
|
+
protected _sql: lSql.Sql;
|
|
30
|
+
protected _ctr?: sCtr.Ctr;
|
|
31
|
+
constructor(opt: {
|
|
32
|
+
'db': lDb.Pool | lDb.Transaction;
|
|
33
|
+
'ctr'?: sCtr.Ctr;
|
|
34
|
+
'index'?: string | string[];
|
|
35
|
+
'alias'?: string;
|
|
36
|
+
'row'?: Record<string, any>;
|
|
37
|
+
'select'?: string | string[];
|
|
38
|
+
'where'?: string | types.Json;
|
|
39
|
+
'contain'?: {
|
|
40
|
+
'key': string;
|
|
41
|
+
'list': string[];
|
|
42
|
+
};
|
|
43
|
+
'raw'?: boolean;
|
|
44
|
+
'pre'?: string;
|
|
45
|
+
});
|
|
46
|
+
static column(field: string): {
|
|
47
|
+
'type': 'column';
|
|
48
|
+
'token': string;
|
|
49
|
+
'value': string;
|
|
50
|
+
};
|
|
51
|
+
static insert(db: lDb.Pool | lDb.Transaction, cs: string[] | Record<string, any>, vs?: any[] | any[][], opt?: {
|
|
52
|
+
'pre'?: sCtr.Ctr | string;
|
|
53
|
+
'index'?: string;
|
|
54
|
+
}): Promise<boolean | null | false>;
|
|
55
|
+
static insertSql(cs: string[] | Record<string, any>, vs?: any[] | any[][], opt?: {
|
|
56
|
+
'pre'?: sCtr.Ctr | string;
|
|
57
|
+
'index'?: string;
|
|
58
|
+
}): string;
|
|
59
|
+
static insertDuplicate(db: lDb.Pool | lDb.Transaction, data: Record<string, any>, update: types.Json, opt?: {
|
|
60
|
+
'pre'?: sCtr.Ctr | string;
|
|
61
|
+
'index'?: string;
|
|
62
|
+
}): Promise<boolean | null>;
|
|
63
|
+
static removeByWhere(db: lDb.Pool | lDb.Transaction, where: string | types.Json, opt?: {
|
|
64
|
+
'raw'?: boolean;
|
|
65
|
+
'pre'?: sCtr.Ctr | string;
|
|
66
|
+
'index'?: string;
|
|
67
|
+
'by'?: [string | string[], 'DESC' | 'ASC'];
|
|
68
|
+
'limit'?: [number, number?];
|
|
69
|
+
}): Promise<number | false | null>;
|
|
70
|
+
static removeByWhereSql(db: lDb.Pool | lDb.Transaction, where: string | types.Json, opt?: {
|
|
71
|
+
'raw'?: boolean;
|
|
72
|
+
'pre'?: sCtr.Ctr | string;
|
|
73
|
+
'index'?: string;
|
|
74
|
+
'by'?: [string | string[], 'DESC' | 'ASC'];
|
|
75
|
+
'limit'?: [number, number?];
|
|
76
|
+
}): lSql.Sql;
|
|
77
|
+
static updateByWhere(db: lDb.Pool | lDb.Transaction, data: types.Json, where: string | types.Json, opt?: {
|
|
78
|
+
'raw'?: boolean;
|
|
79
|
+
'pre'?: sCtr.Ctr | string;
|
|
80
|
+
'index'?: string | string[];
|
|
81
|
+
'by'?: [string | string[], 'DESC' | 'ASC'];
|
|
82
|
+
'limit'?: [number, number?];
|
|
83
|
+
}): Promise<number | false | null>;
|
|
84
|
+
static updateByWhereSql(data: types.Json, where: string | types.Json, opt?: {
|
|
85
|
+
'raw'?: boolean;
|
|
86
|
+
'pre'?: sCtr.Ctr | string;
|
|
87
|
+
'index'?: string;
|
|
88
|
+
'by'?: [string | string[], 'DESC' | 'ASC'];
|
|
89
|
+
'limit'?: [number, number?];
|
|
90
|
+
}): lSql.Sql;
|
|
91
|
+
static select<T extends Mod>(db: lDb.Pool | lDb.Transaction, c: string | string[], opt?: {
|
|
92
|
+
'ctr'?: sCtr.Ctr;
|
|
93
|
+
'pre'?: string;
|
|
94
|
+
'index'?: string | string[];
|
|
95
|
+
'alias'?: string;
|
|
96
|
+
'contain'?: {
|
|
97
|
+
'key': string;
|
|
98
|
+
'list': string[];
|
|
99
|
+
};
|
|
100
|
+
}): T & Record<string, any>;
|
|
101
|
+
static where<T extends Mod>(db: lDb.Pool | lDb.Transaction, s?: string | types.Json, opt?: {
|
|
102
|
+
'ctr'?: sCtr.Ctr;
|
|
103
|
+
'raw'?: boolean;
|
|
104
|
+
'pre'?: string;
|
|
105
|
+
'index'?: string | string[];
|
|
106
|
+
'contain'?: {
|
|
107
|
+
'key': string;
|
|
108
|
+
'list': string[];
|
|
109
|
+
};
|
|
110
|
+
}): T & Record<string, any>;
|
|
111
|
+
static getCreate<T extends Mod>(db: lDb.Pool | lDb.Transaction, opt?: {
|
|
112
|
+
'ctr'?: sCtr.Ctr;
|
|
113
|
+
'pre'?: string;
|
|
114
|
+
'index'?: string;
|
|
115
|
+
}): T;
|
|
116
|
+
static find<T extends Mod>(db: lDb.Pool | lDb.Transaction, val: string | number | null, opt?: {
|
|
117
|
+
'ctr'?: sCtr.Ctr;
|
|
118
|
+
'lock'?: boolean;
|
|
119
|
+
'raw'?: boolean;
|
|
120
|
+
'pre'?: string;
|
|
121
|
+
'index'?: string;
|
|
122
|
+
}): Promise<false | null | (T & Record<string, any>)>;
|
|
123
|
+
static one(db: lDb.Pool | lDb.Transaction, s: string | types.Json, opt: {
|
|
124
|
+
'ctr'?: sCtr.Ctr;
|
|
125
|
+
'raw'?: boolean;
|
|
126
|
+
'pre'?: string;
|
|
127
|
+
'index'?: string | string[];
|
|
128
|
+
'select'?: string | string[];
|
|
129
|
+
'by'?: [string | string[], 'DESC' | 'ASC'];
|
|
130
|
+
'array': true;
|
|
131
|
+
}): Promise<false | null | Record<string, any>>;
|
|
132
|
+
static one<T extends Mod>(db: lDb.Pool | lDb.Transaction, s: string | types.Json, opt: {
|
|
133
|
+
'ctr'?: sCtr.Ctr;
|
|
134
|
+
'raw'?: boolean;
|
|
135
|
+
'pre'?: string;
|
|
136
|
+
'index'?: string | string[];
|
|
137
|
+
'select'?: string | string[];
|
|
138
|
+
'by'?: [string | string[], 'DESC' | 'ASC'];
|
|
139
|
+
'array'?: false;
|
|
140
|
+
}): Promise<false | null | (T & Record<string, any>)>;
|
|
141
|
+
static oneArray(db: lDb.Pool | lDb.Transaction, s: string | types.Json, opt?: {
|
|
142
|
+
'ctr'?: sCtr.Ctr;
|
|
143
|
+
'raw'?: boolean;
|
|
144
|
+
'pre'?: string;
|
|
145
|
+
'index'?: string | string[];
|
|
146
|
+
'select'?: string | string[];
|
|
147
|
+
}): Promise<false | null | Record<string, any>>;
|
|
148
|
+
static primarys(db: lDb.Pool | lDb.Transaction, where?: string | types.Json, opt?: {
|
|
149
|
+
'ctr'?: sCtr.Ctr;
|
|
150
|
+
'raw'?: boolean;
|
|
151
|
+
'pre'?: string;
|
|
152
|
+
'index'?: string;
|
|
153
|
+
}): Promise<any[] | false>;
|
|
154
|
+
static toArrayByRecord<T extends Mod>(obj: Record<string, T>): Record<string, Record<string, any>>;
|
|
155
|
+
set<T extends this, TK extends keyof T>(n: Record<TK, T[TK] | undefined>): void;
|
|
156
|
+
set<T extends this, TK extends keyof T>(n: TK, v: T[TK]): void;
|
|
157
|
+
get(n: string): any;
|
|
158
|
+
create(notWhere?: string | types.Json, table?: string): Promise<boolean>;
|
|
159
|
+
replace(): Promise<boolean>;
|
|
160
|
+
refresh(lock?: boolean): Promise<boolean | null>;
|
|
161
|
+
save(): Promise<boolean>;
|
|
162
|
+
remove(raw?: boolean): Promise<boolean>;
|
|
163
|
+
first(lock: boolean, array: true): Promise<false | null | Record<string, any>>;
|
|
164
|
+
first(lock?: boolean, array?: false): Promise<false | null | (this & Record<string, any>)>;
|
|
165
|
+
firstArray(lock?: boolean): Promise<Record<string, any> | false | null>;
|
|
166
|
+
union(f: lSql.Sql | string | types.IModUnionItem | string[] | types.IModUnionItem[], type?: string): this;
|
|
167
|
+
unionAll(f: lSql.Sql | string | types.IModUnionItem | string[] | types.IModUnionItem[]): this;
|
|
168
|
+
all(): Promise<false | Rows<this>>;
|
|
169
|
+
all(key: string): Promise<false | Record<string, this>>;
|
|
170
|
+
allArray(): Promise<false | Array<Record<string, any>>>;
|
|
171
|
+
allArray(key: string): Promise<false | Record<string, Record<string, any>>>;
|
|
172
|
+
explain(all?: false): Promise<false | string>;
|
|
173
|
+
explain(all: true): Promise<false | Record<string, any>>;
|
|
174
|
+
private _formatTotal;
|
|
175
|
+
total(f?: string): Promise<number>;
|
|
176
|
+
count(): Promise<number>;
|
|
177
|
+
join(f: string, s?: types.Json, type?: string, index?: string, pre?: string): this;
|
|
178
|
+
leftJoin(f: string, s: types.Json, index?: string, pre?: string): this;
|
|
179
|
+
rightJoin(f: string, s: types.Json, index?: string, pre?: string): this;
|
|
180
|
+
innerJoin(f: string, s: types.Json, index?: string, pre?: string): this;
|
|
181
|
+
fullJoin(f: string, s: types.Json, index?: string, pre?: string): this;
|
|
182
|
+
crossJoin(f: string, s: types.Json, index?: string, pre?: string): this;
|
|
183
|
+
having(s: types.Json): this;
|
|
184
|
+
filter(s: types.Json, raw?: boolean): this;
|
|
185
|
+
where(s: types.Json, raw?: boolean): this;
|
|
186
|
+
by(c: string | Array<string | string[]>, d?: 'DESC' | 'ASC'): this;
|
|
187
|
+
group(c: string | string[]): this;
|
|
188
|
+
private _limit;
|
|
189
|
+
limit(a: number, b?: number): this;
|
|
190
|
+
page(count: number, page?: number): this;
|
|
191
|
+
append(sql: string): this;
|
|
192
|
+
contain(contain: {
|
|
193
|
+
'key': string;
|
|
194
|
+
'list': string[];
|
|
195
|
+
}): this;
|
|
196
|
+
getSql(): string;
|
|
197
|
+
getData(): any[];
|
|
198
|
+
format(sql?: string, data?: any[]): string;
|
|
199
|
+
toArray(): Record<string, any>;
|
|
200
|
+
updates(): Record<string, any>;
|
|
201
|
+
unsaved(): boolean;
|
|
202
|
+
langText(col: string, lang: string): string;
|
|
203
|
+
protected _keyGenerator(): string;
|
|
204
|
+
}
|
|
205
|
+
export {};
|
package/sys/mod.js
CHANGED
|
@@ -33,11 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const lSql = __importStar(require("
|
|
37
|
-
const lTime = __importStar(require("
|
|
38
|
-
const lCore = __importStar(require("
|
|
39
|
-
const lText = __importStar(require("
|
|
40
|
-
const sCtr = __importStar(require("
|
|
36
|
+
const lSql = __importStar(require("../lib/sql"));
|
|
37
|
+
const lTime = __importStar(require("../lib/time"));
|
|
38
|
+
const lCore = __importStar(require("../lib/core"));
|
|
39
|
+
const lText = __importStar(require("../lib/text"));
|
|
40
|
+
const sCtr = __importStar(require("../sys/ctr"));
|
|
41
41
|
class Rows {
|
|
42
42
|
constructor(initialItems = []) {
|
|
43
43
|
this._items = [];
|
package/sys/route.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as http2 from 'http2';
|
|
3
|
+
import * as net from 'net';
|
|
4
|
+
import * as sCtr from './ctr';
|
|
5
|
+
import * as types from '../types';
|
|
6
|
+
export declare function clearKebabConfigs(): void;
|
|
7
|
+
export declare function run(data: {
|
|
8
|
+
'req': http2.Http2ServerRequest | http.IncomingMessage;
|
|
9
|
+
'res'?: http2.Http2ServerResponse | http.ServerResponse;
|
|
10
|
+
'socket'?: net.Socket;
|
|
11
|
+
'uri': types.IUrlParse;
|
|
12
|
+
'rootPath': string;
|
|
13
|
+
'urlBase': string;
|
|
14
|
+
'path': string;
|
|
15
|
+
'timer'?: {
|
|
16
|
+
'timer': NodeJS.Timeout;
|
|
17
|
+
'timeout': number;
|
|
18
|
+
'callback': () => void;
|
|
19
|
+
};
|
|
20
|
+
}): Promise<boolean>;
|
|
21
|
+
export declare function unlinkUploadFiles(cctr: sCtr.Ctr | Record<string, types.IPostFile | types.IPostFile[]>): Promise<void>;
|
|
22
|
+
export declare function waitCtr(cctr: sCtr.Ctr): Promise<void>;
|
|
23
|
+
export declare function trimPost(post: Record<string, types.Json>): void;
|
|
24
|
+
export declare function getFormData(req: http2.Http2ServerRequest | http.IncomingMessage, events?: {
|
|
25
|
+
onfilestart?: (name: string) => boolean | undefined;
|
|
26
|
+
onfiledata?: (chunk: Buffer) => void;
|
|
27
|
+
onfileend?: () => void;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
'post': Record<string, types.Json>;
|
|
30
|
+
'files': Record<string, types.IPostFile | types.IPostFile[]>;
|
|
31
|
+
} | false>;
|
package/sys/route.js
CHANGED
|
@@ -42,15 +42,15 @@ exports.getFormData = getFormData;
|
|
|
42
42
|
const http = __importStar(require("http"));
|
|
43
43
|
const stream = __importStar(require("stream"));
|
|
44
44
|
const ws = __importStar(require("@litert/websocket"));
|
|
45
|
-
const lFs = __importStar(require("
|
|
46
|
-
const lZlib = __importStar(require("
|
|
47
|
-
const lCore = __importStar(require("
|
|
48
|
-
const lText = __importStar(require("
|
|
49
|
-
const lTime = __importStar(require("
|
|
50
|
-
const lResponse = __importStar(require("
|
|
51
|
-
const lWs = __importStar(require("
|
|
45
|
+
const lFs = __importStar(require("../lib/fs"));
|
|
46
|
+
const lZlib = __importStar(require("../lib/zlib"));
|
|
47
|
+
const lCore = __importStar(require("../lib/core"));
|
|
48
|
+
const lText = __importStar(require("../lib/text"));
|
|
49
|
+
const lTime = __importStar(require("../lib/time"));
|
|
50
|
+
const lResponse = __importStar(require("../lib/net/response"));
|
|
51
|
+
const lWs = __importStar(require("../lib/ws"));
|
|
52
52
|
const sCtr = __importStar(require("./ctr"));
|
|
53
|
-
const kebab = __importStar(require("
|
|
53
|
+
const kebab = __importStar(require("../index"));
|
|
54
54
|
let kebabConfigs = {};
|
|
55
55
|
function clearKebabConfigs() {
|
|
56
56
|
kebabConfigs = {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project: Kebab, User: JianSuoQiYue
|
|
3
|
+
* Date: 2022-07-22 13:44:12
|
|
4
|
+
* Last: 2022-07-22 13:44:12, 2023-5-2 21:12:32, 2023-12-14 11:43:09
|
|
5
|
+
*/
|
|
6
|
+
import * as http from 'http';
|
|
7
|
+
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
|
+
|
|
10
|
+
/** --- 除非确定是不可知的 Json,否则不能使用 --- */
|
|
11
|
+
export type Json = any;
|
|
12
|
+
|
|
13
|
+
/* eslint-enable */
|
|
14
|
+
|
|
15
|
+
/** --- 数据库值的类型 --- */
|
|
16
|
+
export type DbValue = string | number | null | Record<string, Json>;
|
|
17
|
+
|
|
18
|
+
/** --- mod ls 对象 --- */
|
|
19
|
+
export declare class Rows<T> implements Iterable<T> {
|
|
20
|
+
|
|
21
|
+
/** --- 总行数 --- */
|
|
22
|
+
public get length(): number;
|
|
23
|
+
|
|
24
|
+
/** --- 通过索引获取一个对象 --- */
|
|
25
|
+
public item(index: number): T;
|
|
26
|
+
|
|
27
|
+
/** --- 转换为数组对象 --- */
|
|
28
|
+
public toArray(): Array<Record<string, DbValue>>;
|
|
29
|
+
|
|
30
|
+
public [Symbol.iterator](): Iterator<T>;
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** --- 虚拟机配置对象 --- */
|
|
35
|
+
export interface IVhost {
|
|
36
|
+
readonly 'name': string;
|
|
37
|
+
readonly 'domains': string[];
|
|
38
|
+
readonly 'root': string;
|
|
39
|
+
readonly 'remark': string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** --- 上传的文件信息对象 --- */
|
|
43
|
+
export interface IPostFile {
|
|
44
|
+
readonly 'name': string;
|
|
45
|
+
readonly 'origin': string;
|
|
46
|
+
readonly 'size': number;
|
|
47
|
+
readonly 'path': string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** --- 动态目录配置文件 --- */
|
|
51
|
+
export interface IConfig {
|
|
52
|
+
'set': {
|
|
53
|
+
'timezone': number;
|
|
54
|
+
'mustHttps': boolean;
|
|
55
|
+
'cacheTtl': number;
|
|
56
|
+
|
|
57
|
+
'staticVer': string;
|
|
58
|
+
'staticPath': string;
|
|
59
|
+
'staticPathFull': string;
|
|
60
|
+
|
|
61
|
+
[key: string]: Json;
|
|
62
|
+
};
|
|
63
|
+
'const': IConfigConst;
|
|
64
|
+
'db': IConfigDb;
|
|
65
|
+
'jwt': IConfigJwt;
|
|
66
|
+
'kv': IConfigKv;
|
|
67
|
+
'route': Record<string, string>;
|
|
68
|
+
'session': {
|
|
69
|
+
'name': string;
|
|
70
|
+
'ttl': number;
|
|
71
|
+
'ssl': boolean;
|
|
72
|
+
};
|
|
73
|
+
'sql': IConfigSql;
|
|
74
|
+
'dns': Record<string, IConfigDns>;
|
|
75
|
+
'lang': IConfigLang;
|
|
76
|
+
's3': Record<string, IConfigS3>;
|
|
77
|
+
'turnstile': IConfigTurnstile;
|
|
78
|
+
|
|
79
|
+
[key: string]: Record<string, Json>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** --- 动配数据库 --- */
|
|
83
|
+
export interface IConfigLang {
|
|
84
|
+
'list': string[];
|
|
85
|
+
'direct': string[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** --- 动配对象存储信息 --- */
|
|
89
|
+
export interface IConfigS3 {
|
|
90
|
+
/** --- cf r2 要用 --- */
|
|
91
|
+
'account'?: string;
|
|
92
|
+
'sid': string;
|
|
93
|
+
'skey': string;
|
|
94
|
+
'region': string;
|
|
95
|
+
'bucket': string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** --- 动配对象存储信息 --- */
|
|
99
|
+
export interface IConfigTurnstile {
|
|
100
|
+
'CF': {
|
|
101
|
+
'sid': string;
|
|
102
|
+
'skey': string;
|
|
103
|
+
},
|
|
104
|
+
'TENCENT': {
|
|
105
|
+
'sid': string;
|
|
106
|
+
'skey': string;
|
|
107
|
+
'aid': string;
|
|
108
|
+
'akey': string;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** --- 动配数据库 --- */
|
|
113
|
+
export interface IConfigDb {
|
|
114
|
+
'host': string;
|
|
115
|
+
'port': number;
|
|
116
|
+
'charset': string;
|
|
117
|
+
'name': string;
|
|
118
|
+
|
|
119
|
+
'user': string;
|
|
120
|
+
'pwd': string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** --- Jwt 信息 --- */
|
|
124
|
+
export interface IConfigJwt {
|
|
125
|
+
'name': string;
|
|
126
|
+
'ttl': number;
|
|
127
|
+
'ssl': boolean;
|
|
128
|
+
'secret': string;
|
|
129
|
+
'auth': boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** --- DNS --- */
|
|
133
|
+
export interface IConfigDns {
|
|
134
|
+
'sid': string;
|
|
135
|
+
'skey': string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** --- 动配 kv --- */
|
|
139
|
+
export interface IConfigKv {
|
|
140
|
+
'host': string;
|
|
141
|
+
'port': number;
|
|
142
|
+
'index': number;
|
|
143
|
+
'pre': string;
|
|
144
|
+
|
|
145
|
+
'user': string;
|
|
146
|
+
'pwd': string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** --- 动配 sql --- */
|
|
150
|
+
export interface IConfigSql {
|
|
151
|
+
'pre': string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** --- 动配常量 --- */
|
|
155
|
+
export interface IConfigConst {
|
|
156
|
+
'path': string;
|
|
157
|
+
'qs': string;
|
|
158
|
+
'startTime': bigint;
|
|
159
|
+
'startMemory': number;
|
|
160
|
+
|
|
161
|
+
// --- 环境判断 ---
|
|
162
|
+
|
|
163
|
+
'mobile': boolean;
|
|
164
|
+
'wechat': boolean;
|
|
165
|
+
'https': boolean;
|
|
166
|
+
'host': string;
|
|
167
|
+
'hostname': string;
|
|
168
|
+
'hostport': number;
|
|
169
|
+
'uri': IUrlParse;
|
|
170
|
+
|
|
171
|
+
// --- 服务端用的路径 ---
|
|
172
|
+
|
|
173
|
+
'rootPath': string;
|
|
174
|
+
'modPath': string;
|
|
175
|
+
'ctrPath': string;
|
|
176
|
+
'viewPath': string;
|
|
177
|
+
'dataPath': string;
|
|
178
|
+
'wsPath': string;
|
|
179
|
+
|
|
180
|
+
// --- 前端用的路径 ---
|
|
181
|
+
|
|
182
|
+
'urlBase': string;
|
|
183
|
+
'urlStc': string;
|
|
184
|
+
'urlFull': string;
|
|
185
|
+
'urlStcFull': string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** --- http headers --- */
|
|
189
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
190
|
+
export type THttpHeaders = http.IncomingHttpHeaders & {
|
|
191
|
+
'http-version'?: '1.1' | '2.0';
|
|
192
|
+
'http-code'?: number;
|
|
193
|
+
'http-url'?: string;
|
|
194
|
+
};
|
|
195
|
+
/* eslint-enable */
|
|
196
|
+
|
|
197
|
+
/** --- Net Cookie 对象 --- */
|
|
198
|
+
export interface ICookie {
|
|
199
|
+
'name': string;
|
|
200
|
+
'value': string;
|
|
201
|
+
/** --- 有效期秒级时间戳 --- */
|
|
202
|
+
'exp': number;
|
|
203
|
+
'path': string;
|
|
204
|
+
'domain': string;
|
|
205
|
+
'secure': boolean;
|
|
206
|
+
'httponly': boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface IUrlParse {
|
|
210
|
+
'protocol': string | null;
|
|
211
|
+
'auth': string | null;
|
|
212
|
+
'user': string | null;
|
|
213
|
+
'pass': string | null;
|
|
214
|
+
'host': string | null;
|
|
215
|
+
'hostname': string | null;
|
|
216
|
+
'port': string | null;
|
|
217
|
+
'pathname': string;
|
|
218
|
+
'path': string | null;
|
|
219
|
+
'query': string | null;
|
|
220
|
+
'hash': string | null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface IModUnionItem {
|
|
224
|
+
'field': string;
|
|
225
|
+
'where'?: any;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// -------------------------
|
|
229
|
+
// -------- zip lib --------
|
|
230
|
+
// -------------------------
|
|
231
|
+
|
|
232
|
+
export interface IZipItem {
|
|
233
|
+
'name': string;
|
|
234
|
+
'compressedSize': number;
|
|
235
|
+
'uncompressedSize': number;
|
|
236
|
+
'date': Date;
|
|
237
|
+
'isFile': boolean;
|
|
238
|
+
'isDirectory': boolean;
|
|
239
|
+
'path': string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export interface IZipStats {
|
|
243
|
+
'compressedSize': number;
|
|
244
|
+
'uncompressedSize': number;
|
|
245
|
+
'date': Date;
|
|
246
|
+
'isFile': boolean;
|
|
247
|
+
'isDirectory': boolean;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface IZipOutputByType {
|
|
251
|
+
'base64': string;
|
|
252
|
+
'string': string;
|
|
253
|
+
'text': string;
|
|
254
|
+
'binarystring': string;
|
|
255
|
+
'array': number[];
|
|
256
|
+
'uint8array': Uint8Array;
|
|
257
|
+
'arraybuffer': ArrayBuffer;
|
|
258
|
+
'blob': Blob;
|
|
259
|
+
'nodebuffer': Buffer;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export type TZipOutputType = keyof IZipOutputByType;
|
|
263
|
+
|
|
264
|
+
export interface IZipInputByType {
|
|
265
|
+
'base64': string;
|
|
266
|
+
'string': string;
|
|
267
|
+
'text': string;
|
|
268
|
+
'binarystring': string;
|
|
269
|
+
'array': number[];
|
|
270
|
+
'uint8array': Uint8Array;
|
|
271
|
+
'arraybuffer': ArrayBuffer;
|
|
272
|
+
'blob': Blob;
|
|
273
|
+
'nodebuffer': Buffer;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export type TZipInputType = keyof IZipInputByType;
|
|
277
|
+
|
|
278
|
+
export type TZipInputFileFormat = IZipInputByType[keyof IZipInputByType];
|
|
279
|
+
|
|
280
|
+
export interface IZipMetadata {
|
|
281
|
+
'percent': number;
|
|
282
|
+
'currentFile': string | null;
|
|
283
|
+
}
|
package/www/example/ctr/main.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const ctr = __importStar(require("
|
|
36
|
+
const ctr = __importStar(require("../../../sys/ctr"));
|
|
37
37
|
class default_1 extends ctr.Ctr {
|
|
38
38
|
index() {
|
|
39
39
|
return `<a href="${this._config.const.urlBase}test">Hello world! Click here to visit demo.</a>`;
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const ctr = __importStar(require("
|
|
36
|
+
const ctr = __importStar(require("../../../sys/ctr"));
|
|
37
37
|
class default_1 extends ctr.Ctr {
|
|
38
38
|
onLoad() {
|
|
39
39
|
if (this._config.const.path !== 'test/middle') {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as sCtr from '../../../sys/ctr';
|
|
3
|
+
import * as types from '../../../types';
|
|
4
|
+
export default class extends sCtr.Ctr {
|
|
5
|
+
private _internalUrl;
|
|
6
|
+
onLoad(): Array<string | number> | boolean;
|
|
7
|
+
onUnload(rtn: string | boolean | types.DbValue[]): string | boolean | types.DbValue[];
|
|
8
|
+
notfound(): string;
|
|
9
|
+
index(): string;
|
|
10
|
+
article(): string;
|
|
11
|
+
qs(): string;
|
|
12
|
+
view(): Promise<string>;
|
|
13
|
+
json(): Array<number | string | object> | object;
|
|
14
|
+
ctrXsrf(): string;
|
|
15
|
+
ctrXsrf1(): types.Json[];
|
|
16
|
+
ctrCheckinput(): string;
|
|
17
|
+
ctrCheckinput1(): Promise<types.Json[]>;
|
|
18
|
+
ctrLocale(): Promise<types.Json[] | string>;
|
|
19
|
+
ctrCachettl(): string;
|
|
20
|
+
ctrHttpcode(): string;
|
|
21
|
+
ctrCross(): string;
|
|
22
|
+
ctrCross1(): types.Json[];
|
|
23
|
+
ctrCross2(): types.Json[];
|
|
24
|
+
ctrReadable(): fs.ReadStream;
|
|
25
|
+
ctrAsynctask(): any[];
|
|
26
|
+
ctrTimeout(): Promise<any[]>;
|
|
27
|
+
modTest(): Promise<types.Json[] | string | boolean>;
|
|
28
|
+
modSplit(): Promise<string>;
|
|
29
|
+
modSplit1(): Promise<void>;
|
|
30
|
+
modSplit2(): Promise<types.Json[]>;
|
|
31
|
+
captchaFastbuild(): string;
|
|
32
|
+
captchaBase64(): string;
|
|
33
|
+
coreRandom(): string;
|
|
34
|
+
coreRand(): string;
|
|
35
|
+
coreConvert62(): string;
|
|
36
|
+
corePurify(): string;
|
|
37
|
+
coreChecktype(): string;
|
|
38
|
+
coreMuid(): string;
|
|
39
|
+
coreGetlog(): Promise<string>;
|
|
40
|
+
coreUpdatecode(): Promise<string>;
|
|
41
|
+
coreReload(): Promise<string>;
|
|
42
|
+
coreRestart(): Promise<string>;
|
|
43
|
+
coreGlobal(): Promise<string>;
|
|
44
|
+
crypto(): Promise<string>;
|
|
45
|
+
db(): Promise<types.Json>;
|
|
46
|
+
private _dbTable;
|
|
47
|
+
kv(): Promise<types.Json>;
|
|
48
|
+
net(): Promise<string>;
|
|
49
|
+
netPipe(): Promise<types.Json>;
|
|
50
|
+
netPost(): Promise<types.Json>;
|
|
51
|
+
netPost1(): string;
|
|
52
|
+
netPostString(): Promise<string>;
|
|
53
|
+
netPostString1(): types.Json[];
|
|
54
|
+
netOpen(): Promise<types.Json>;
|
|
55
|
+
netFormTest(): Promise<string>;
|
|
56
|
+
netUpload(): Promise<string>;
|
|
57
|
+
netUpload1(): Promise<string>;
|
|
58
|
+
netCookie(): Promise<string>;
|
|
59
|
+
netCookie1(): string;
|
|
60
|
+
netCookie2(): string;
|
|
61
|
+
netSave(): Promise<string>;
|
|
62
|
+
netFollow(): Promise<string>;
|
|
63
|
+
netFollow1(): void;
|
|
64
|
+
netFollow2(): types.Json;
|
|
65
|
+
netReuse(): Promise<string>;
|
|
66
|
+
netError(): Promise<string>;
|
|
67
|
+
netHosts(): Promise<string>;
|
|
68
|
+
netRproxy(): Promise<string | boolean>;
|
|
69
|
+
netMproxy(): Promise<string | boolean>;
|
|
70
|
+
netMproxy1(): Promise<string | boolean>;
|
|
71
|
+
scan(): Promise<types.Json>;
|
|
72
|
+
scan1(): Promise<types.Json>;
|
|
73
|
+
scan2(): Promise<types.Json>;
|
|
74
|
+
scan3(): Promise<types.Json>;
|
|
75
|
+
private _scanLink;
|
|
76
|
+
session(): Promise<string | types.Json[]>;
|
|
77
|
+
jwt(): Promise<string | types.Json[]>;
|
|
78
|
+
jwt1(): Promise<[number, types.Json]>;
|
|
79
|
+
sql(): string;
|
|
80
|
+
consistentHash(): string;
|
|
81
|
+
consistentDistributed(): string;
|
|
82
|
+
consistentMigration(): string;
|
|
83
|
+
consistentFast(): string;
|
|
84
|
+
text(): string;
|
|
85
|
+
time(): string;
|
|
86
|
+
wsServer(): string;
|
|
87
|
+
wsClient(): Promise<string>;
|
|
88
|
+
ssh(): Promise<string | types.Json[]>;
|
|
89
|
+
s3(): Promise<string>;
|
|
90
|
+
zip(): Promise<string>;
|
|
91
|
+
buffer(): string;
|
|
92
|
+
lan(): Promise<string>;
|
|
93
|
+
private _getEnd;
|
|
94
|
+
}
|