@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/lib/text.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as types from '../types';
|
|
2
|
+
export declare function sizeFormat(size: number, spliter?: string): string;
|
|
3
|
+
export declare function parseUrl(url: string): types.IUrlParse;
|
|
4
|
+
export declare function urlResolve(from: string, to: string): string;
|
|
5
|
+
export declare function urlAtom(url: string): string;
|
|
6
|
+
export declare const REGEXP_EMAIL: RegExp;
|
|
7
|
+
export declare function isEMail(email: string): boolean;
|
|
8
|
+
export declare const REGEXP_IPV4: RegExp;
|
|
9
|
+
export declare function isIPv4(ip: string): boolean;
|
|
10
|
+
export declare const REGEXP_IPV6: RegExp;
|
|
11
|
+
export declare function isIPv6(ip: string): boolean;
|
|
12
|
+
export declare const REGEXP_DOMAIN: RegExp;
|
|
13
|
+
export declare function isDomain(domain: string): boolean;
|
|
14
|
+
export declare const REGEXP_ASCII: RegExp;
|
|
15
|
+
export declare function isAscii(text: string): boolean;
|
|
16
|
+
export declare function nlReplace(str: string, to?: string): string;
|
|
17
|
+
export interface IDomain {
|
|
18
|
+
tld: string | null;
|
|
19
|
+
sld: string | null;
|
|
20
|
+
domain: string | null;
|
|
21
|
+
sub: string | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function parseDomain(domain: string): Promise<IDomain>;
|
|
24
|
+
export declare function match(str: string, regs: RegExp[]): boolean;
|
|
25
|
+
export declare function isPhoneCN(p: string): boolean;
|
|
26
|
+
export declare function isIdCardCN(idcard: string): boolean;
|
|
27
|
+
export declare function queryStringify(query: Record<string, any>, encode?: boolean): string;
|
|
28
|
+
export declare function queryParse(query: string): Record<string, string | string[]>;
|
|
29
|
+
export declare function htmlescape(html: string): string;
|
|
30
|
+
export declare function isRealPath(path: string): boolean;
|
|
31
|
+
export declare function getFilename(path: string): string;
|
|
32
|
+
export declare function stringifyResult(rtn: types.Json): string;
|
|
33
|
+
export declare function parseJson(str: string): any;
|
|
34
|
+
export declare function stringifyJson(obj: types.Json, space?: string | number): string;
|
|
35
|
+
type TFalsy = false | '' | 0 | null | undefined | typeof NaN;
|
|
36
|
+
export declare function isFalsy(val: any): val is TFalsy;
|
|
37
|
+
export declare function logicalOr<T, T2>(v1: T, v2: T2): [T] extends [TFalsy] ? T2 : T;
|
|
38
|
+
export declare function str2int(str: string, digits?: number): number;
|
|
39
|
+
export declare function int2str(int: number, digits?: number, decimal?: number): string;
|
|
40
|
+
export {};
|
package/lib/text.js
CHANGED
|
@@ -60,7 +60,7 @@ exports.isFalsy = isFalsy;
|
|
|
60
60
|
exports.logicalOr = logicalOr;
|
|
61
61
|
exports.str2int = str2int;
|
|
62
62
|
exports.int2str = int2str;
|
|
63
|
-
const kebab = __importStar(require("
|
|
63
|
+
const kebab = __importStar(require("../index"));
|
|
64
64
|
const fs = __importStar(require("./fs"));
|
|
65
65
|
function sizeFormat(size, spliter = ' ') {
|
|
66
66
|
const units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
package/lib/time.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as sCtr from '../sys/ctr';
|
|
2
|
+
export interface IOptions {
|
|
3
|
+
'zone'?: number;
|
|
4
|
+
'data'?: string | number;
|
|
5
|
+
}
|
|
6
|
+
export declare const HOUR = 3600;
|
|
7
|
+
export declare const DAY = 86400;
|
|
8
|
+
export declare const YEAR = 31536000;
|
|
9
|
+
export declare class Time {
|
|
10
|
+
private readonly _date;
|
|
11
|
+
private _zone;
|
|
12
|
+
constructor(ctr: sCtr.Ctr, opt: IOptions);
|
|
13
|
+
setZone(zone: number): void;
|
|
14
|
+
getZone(): number;
|
|
15
|
+
toUTCString(): string;
|
|
16
|
+
format(f: string, zone?: number): string;
|
|
17
|
+
stamp(): number;
|
|
18
|
+
}
|
|
19
|
+
export declare function get(ctr: sCtr.Ctr, opt?: IOptions): Time;
|
|
20
|
+
export declare function stamp(date?: Date | string, zone?: number | sCtr.Ctr | null): number;
|
|
21
|
+
export declare function isMs(time: number): boolean;
|
|
22
|
+
export declare function format(zone: number | sCtr.Ctr | null, f: string, date?: Date | number): string;
|
package/lib/time.js
CHANGED
|
@@ -38,7 +38,7 @@ exports.get = get;
|
|
|
38
38
|
exports.stamp = stamp;
|
|
39
39
|
exports.isMs = isMs;
|
|
40
40
|
exports.format = format;
|
|
41
|
-
const sCtr = __importStar(require("
|
|
41
|
+
const sCtr = __importStar(require("../sys/ctr"));
|
|
42
42
|
exports.HOUR = 3600;
|
|
43
43
|
exports.DAY = 86400;
|
|
44
44
|
exports.YEAR = 31536000;
|
package/lib/ws.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as net from 'net';
|
|
3
|
+
import * as types from '../types';
|
|
4
|
+
import * as sCtr from '../sys/ctr';
|
|
5
|
+
export declare enum EFrameReceiveMode {
|
|
6
|
+
STANDARD = 0,
|
|
7
|
+
LITE = 1,
|
|
8
|
+
SIMPLE = 2
|
|
9
|
+
}
|
|
10
|
+
export declare enum EOpcode {
|
|
11
|
+
CONTINUATION = 0,
|
|
12
|
+
TEXT = 1,
|
|
13
|
+
BINARY = 2,
|
|
14
|
+
CLOSE = 8,
|
|
15
|
+
PING = 9,
|
|
16
|
+
PONG = 10
|
|
17
|
+
}
|
|
18
|
+
export interface IConnectOptions {
|
|
19
|
+
'timeout'?: number;
|
|
20
|
+
'hosts'?: Record<string, string>;
|
|
21
|
+
'local'?: string;
|
|
22
|
+
'headers'?: types.THttpHeaders;
|
|
23
|
+
'cookie'?: Record<string, types.ICookie>;
|
|
24
|
+
'mode'?: EFrameReceiveMode;
|
|
25
|
+
'masking'?: boolean;
|
|
26
|
+
'mproxy'?: {
|
|
27
|
+
'url': string;
|
|
28
|
+
'auth': string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface IMproxyOptions {
|
|
32
|
+
'timeout'?: number;
|
|
33
|
+
'hosts'?: Record<string, string>;
|
|
34
|
+
'local'?: string;
|
|
35
|
+
'headers'?: types.THttpHeaders;
|
|
36
|
+
'mode'?: EFrameReceiveMode;
|
|
37
|
+
'masking'?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface IRproxyOptions {
|
|
40
|
+
'timeout'?: number;
|
|
41
|
+
'hosts'?: Record<string, string>;
|
|
42
|
+
'local'?: string;
|
|
43
|
+
'headers'?: types.THttpHeaders;
|
|
44
|
+
'mode'?: EFrameReceiveMode;
|
|
45
|
+
'masking'?: boolean;
|
|
46
|
+
'mproxy'?: {
|
|
47
|
+
'url': string;
|
|
48
|
+
'auth': string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare class Socket {
|
|
52
|
+
private _ws;
|
|
53
|
+
constructor(request?: http.IncomingMessage, socket?: net.Socket, options?: {
|
|
54
|
+
'headers'?: http.OutgoingHttpHeaders;
|
|
55
|
+
'timeout'?: number;
|
|
56
|
+
});
|
|
57
|
+
connect(u: string, opt?: IConnectOptions): Promise<this | null>;
|
|
58
|
+
private _bindEvent;
|
|
59
|
+
private readonly _waitMsg;
|
|
60
|
+
private _error;
|
|
61
|
+
private _close;
|
|
62
|
+
private _on;
|
|
63
|
+
on(event: 'message', cb: (msg: {
|
|
64
|
+
'opcode': EOpcode;
|
|
65
|
+
'data': Buffer | string;
|
|
66
|
+
}) => void | Promise<void>): this;
|
|
67
|
+
on(event: 'error', cb: (error: any) => void | Promise<void>): this;
|
|
68
|
+
on(event: 'drain' | 'close' | 'end', cb: () => void | Promise<void>): this;
|
|
69
|
+
end(): void;
|
|
70
|
+
destroy(): void;
|
|
71
|
+
writeText(data: string): boolean;
|
|
72
|
+
writeResult(data: types.Json): boolean;
|
|
73
|
+
writeBinary(data: string | Buffer | Array<string | Buffer>): boolean;
|
|
74
|
+
get writable(): boolean;
|
|
75
|
+
get ended(): boolean;
|
|
76
|
+
get finished(): boolean;
|
|
77
|
+
get isServer(): boolean;
|
|
78
|
+
ping(data?: Buffer | string): boolean;
|
|
79
|
+
pong(data?: Buffer | string): boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare function connect(u: string, opt?: IConnectOptions): Promise<Socket | null>;
|
|
82
|
+
export declare function createServer(request: http.IncomingMessage, socket: net.Socket, options?: {
|
|
83
|
+
'headers'?: http.OutgoingHttpHeaders;
|
|
84
|
+
'timeout'?: number;
|
|
85
|
+
}): Socket;
|
|
86
|
+
export declare function mproxy(ctr: sCtr.Ctr, auth: string, opt?: IMproxyOptions): Promise<number>;
|
|
87
|
+
export declare function rproxy(ctr: sCtr.Ctr, url: string, opt?: IRproxyOptions): Promise<boolean>;
|
package/lib/ws.js
CHANGED
|
@@ -39,8 +39,8 @@ exports.createServer = createServer;
|
|
|
39
39
|
exports.mproxy = mproxy;
|
|
40
40
|
exports.rproxy = rproxy;
|
|
41
41
|
const liws = __importStar(require("@litert/websocket"));
|
|
42
|
-
const lText = __importStar(require("
|
|
43
|
-
const lNet = __importStar(require("
|
|
42
|
+
const lText = __importStar(require("../lib/text"));
|
|
43
|
+
const lNet = __importStar(require("../lib/net"));
|
|
44
44
|
var EFrameReceiveMode;
|
|
45
45
|
(function (EFrameReceiveMode) {
|
|
46
46
|
EFrameReceiveMode[EFrameReceiveMode["STANDARD"] = 0] = "STANDARD";
|
package/lib/zip.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import jszip from 'jszip';
|
|
2
|
+
import * as types from '../types';
|
|
3
|
+
export declare class Zip {
|
|
4
|
+
private readonly _zip;
|
|
5
|
+
private _path;
|
|
6
|
+
constructor(zip: jszip);
|
|
7
|
+
getContent(path: string): Promise<string | null>;
|
|
8
|
+
getContent<T extends types.TZipOutputType>(path: string, type: T): Promise<types.IZipOutputByType[T] | null>;
|
|
9
|
+
putContent<T extends types.TZipInputType>(path: string, data: types.IZipInputByType[T], options?: {
|
|
10
|
+
'base64'?: boolean;
|
|
11
|
+
'binary'?: boolean;
|
|
12
|
+
'date'?: Date;
|
|
13
|
+
}): void;
|
|
14
|
+
unlink(path: string): void;
|
|
15
|
+
stats(path: string): types.IZipStats | null;
|
|
16
|
+
isDir(path: string): types.IZipStats | false;
|
|
17
|
+
isFile(path: string): types.IZipStats | false;
|
|
18
|
+
readDir(path?: string, opt?: {
|
|
19
|
+
'hasChildren'?: boolean;
|
|
20
|
+
'hasDir'?: boolean;
|
|
21
|
+
'pathAsKey'?: false;
|
|
22
|
+
}): types.IZipItem[];
|
|
23
|
+
readDir(path?: string, opt?: {
|
|
24
|
+
'hasChildren'?: boolean;
|
|
25
|
+
'hasDir'?: boolean;
|
|
26
|
+
'pathAsKey': true;
|
|
27
|
+
}): Record<string, types.IZipItem>;
|
|
28
|
+
private _readDir;
|
|
29
|
+
private _list;
|
|
30
|
+
private _refreshList;
|
|
31
|
+
pwd(): string;
|
|
32
|
+
cd(dir: string): string;
|
|
33
|
+
generate<T extends types.TZipOutputType>(options?: {
|
|
34
|
+
'type'?: T;
|
|
35
|
+
'level'?: number;
|
|
36
|
+
'onUpdate'?: (percent: number, currentFile: string | null) => void;
|
|
37
|
+
}): Promise<types.IZipOutputByType[T]>;
|
|
38
|
+
getList(): Promise<Record<string, Buffer | string>>;
|
|
39
|
+
}
|
|
40
|
+
export declare function get(data?: types.TZipInputFileFormat): Promise<Zip | null>;
|
package/lib/zip.js
CHANGED
|
@@ -40,7 +40,7 @@ exports.Zip = void 0;
|
|
|
40
40
|
exports.get = get;
|
|
41
41
|
const jszip_1 = __importDefault(require("jszip"));
|
|
42
42
|
const mime = __importStar(require("@litert/mime"));
|
|
43
|
-
const lText = __importStar(require("
|
|
43
|
+
const lText = __importStar(require("../lib/text"));
|
|
44
44
|
class Zip {
|
|
45
45
|
constructor(zip) {
|
|
46
46
|
this._path = '/';
|
package/lib/zlib.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as zlib from 'zlib';
|
|
2
|
+
export interface ICompress {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly compress: zlib.Deflate | zlib.Gzip | zlib.BrotliCompress | zlib.Inflate | zlib.Gunzip | zlib.BrotliDecompress;
|
|
5
|
+
}
|
|
6
|
+
export interface ICompressBuffer {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly buffer: Buffer;
|
|
9
|
+
}
|
|
10
|
+
export declare function createGzip(options?: zlib.ZlibOptions): zlib.Gzip;
|
|
11
|
+
export declare function createGunzip(): zlib.Gunzip;
|
|
12
|
+
export declare function createDeflate(options?: zlib.ZlibOptions): zlib.Deflate;
|
|
13
|
+
export declare function createInflate(): zlib.Inflate;
|
|
14
|
+
export declare function createBrotliCompress(options?: zlib.ZlibOptions): zlib.BrotliCompress;
|
|
15
|
+
export declare function createBrotliDecompress(): zlib.BrotliDecompress;
|
|
16
|
+
export declare function createCompress(types: string, options?: zlib.ZlibOptions): ICompress | null;
|
|
17
|
+
export declare function createDecompress(types: string): ICompress | null;
|
|
18
|
+
export declare function gzip(buffer: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer | null>;
|
|
19
|
+
export declare function gunzip(buffer: zlib.InputType): Promise<Buffer | null>;
|
|
20
|
+
export declare function deflate(buffer: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer | null>;
|
|
21
|
+
export declare function inflate(buffer: zlib.InputType): Promise<Buffer | null>;
|
|
22
|
+
export declare function brotliCompress(buffer: zlib.InputType, options?: zlib.ZlibOptions): Promise<Buffer | null>;
|
|
23
|
+
export declare function brotliDecompress(buffer: zlib.InputType): Promise<Buffer | null>;
|
|
24
|
+
export declare function compress(types: string, buffer: zlib.InputType | null, options?: zlib.ZlibOptions): Promise<ICompressBuffer | null>;
|
|
25
|
+
export declare function decompress(types: string, buffer: zlib.InputType | null): Promise<ICompressBuffer | null>;
|
package/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'ts-alias-loader';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maiyunnet/kebab",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kebab",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"jszip": "^3.10.1",
|
|
25
25
|
"mysql2": "^3.14.1",
|
|
26
26
|
"ssh2": "^1.16.0",
|
|
27
|
-
"svg-captcha": "^1.4.0"
|
|
28
|
-
"ts-alias-loader": "^0.1.5"
|
|
27
|
+
"svg-captcha": "^1.4.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"@litert/eslint-plugin-rules": "^0.3.1",
|
|
32
31
|
"@types/ejs": "^3.1.5",
|
|
33
32
|
"@types/node": "^24.0.0",
|
|
34
33
|
"@types/ssh2": "^1.15.5",
|
|
34
|
+
"tsc-alias": "^1.8.16",
|
|
35
35
|
"typescript": "^5.8.3"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/sys/child.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/sys/child.js
CHANGED
|
@@ -37,12 +37,12 @@ const http2 = __importStar(require("http2"));
|
|
|
37
37
|
const tls = __importStar(require("tls"));
|
|
38
38
|
const http = __importStar(require("http"));
|
|
39
39
|
const crypto = __importStar(require("crypto"));
|
|
40
|
-
const fs = __importStar(require("
|
|
41
|
-
const lCore = __importStar(require("
|
|
42
|
-
const lText = __importStar(require("
|
|
43
|
-
const sCtr = __importStar(require("
|
|
44
|
-
const kebab = __importStar(require("
|
|
45
|
-
const sRoute = __importStar(require("
|
|
40
|
+
const fs = __importStar(require("../lib/fs"));
|
|
41
|
+
const lCore = __importStar(require("../lib/core"));
|
|
42
|
+
const lText = __importStar(require("../lib/text"));
|
|
43
|
+
const sCtr = __importStar(require("../sys/ctr"));
|
|
44
|
+
const kebab = __importStar(require("../index"));
|
|
45
|
+
const sRoute = __importStar(require("../sys/route"));
|
|
46
46
|
const hbTimer = setInterval(function () {
|
|
47
47
|
if (!process.connected || !process.send) {
|
|
48
48
|
return;
|
package/sys/cmd.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/sys/cmd.js
CHANGED
|
@@ -34,12 +34,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const http = __importStar(require("http"));
|
|
37
|
-
const lFs = __importStar(require("
|
|
38
|
-
const lText = __importStar(require("
|
|
39
|
-
const lTime = __importStar(require("
|
|
40
|
-
const lCore = __importStar(require("
|
|
41
|
-
const lCrypto = __importStar(require("
|
|
42
|
-
const kebab = __importStar(require("
|
|
37
|
+
const lFs = __importStar(require("../lib/fs"));
|
|
38
|
+
const lText = __importStar(require("../lib/text"));
|
|
39
|
+
const lTime = __importStar(require("../lib/time"));
|
|
40
|
+
const lCore = __importStar(require("../lib/core"));
|
|
41
|
+
const lCrypto = __importStar(require("../lib/crypto"));
|
|
42
|
+
const kebab = __importStar(require("../index"));
|
|
43
43
|
const cmds = process.argv.slice(2);
|
|
44
44
|
async function initDir(paths) {
|
|
45
45
|
for (const path of paths) {
|
package/sys/ctr.d.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as http2 from 'http2';
|
|
3
|
+
import * as session from '../lib/session';
|
|
4
|
+
import * as db from '../lib/db';
|
|
5
|
+
import * as kv from '../lib/kv';
|
|
6
|
+
import * as lWs from '../lib/ws';
|
|
7
|
+
import * as types from '../types';
|
|
8
|
+
export declare function clearLocaleData(): void;
|
|
9
|
+
export declare class Ctr {
|
|
10
|
+
protected _param: string[];
|
|
11
|
+
protected _action: string;
|
|
12
|
+
protected _headers: http.IncomingHttpHeaders;
|
|
13
|
+
protected _get: Record<string, string>;
|
|
14
|
+
protected _rawPost: Record<string, types.Json>;
|
|
15
|
+
protected _post: Record<string, types.Json>;
|
|
16
|
+
protected _input: string;
|
|
17
|
+
protected _files: Record<string, types.IPostFile | types.IPostFile[]>;
|
|
18
|
+
protected _cookie: Record<string, string>;
|
|
19
|
+
protected _jwt: Record<string, types.Json>;
|
|
20
|
+
protected _session: Record<string, types.Json>;
|
|
21
|
+
protected _sess: session.Session | null;
|
|
22
|
+
protected _cacheTTL: number;
|
|
23
|
+
protected _xsrf: string;
|
|
24
|
+
protected _httpCode: number;
|
|
25
|
+
protected _locale: string;
|
|
26
|
+
protected readonly _config: types.IConfig;
|
|
27
|
+
protected readonly _req: http2.Http2ServerRequest | http.IncomingMessage;
|
|
28
|
+
protected readonly _res: http2.Http2ServerResponse | http.ServerResponse;
|
|
29
|
+
protected readonly _socket: lWs.Socket;
|
|
30
|
+
protected _localeFiles: string[];
|
|
31
|
+
protected _localeData: Record<string, Record<string, string>>;
|
|
32
|
+
constructor(config: types.IConfig, req: http2.Http2ServerRequest | http.IncomingMessage, res?: http2.Http2ServerResponse | http.ServerResponse);
|
|
33
|
+
get isAvail(): boolean;
|
|
34
|
+
protected _timer?: {
|
|
35
|
+
'timer': NodeJS.Timeout;
|
|
36
|
+
'timeout': number;
|
|
37
|
+
'callback': () => void;
|
|
38
|
+
};
|
|
39
|
+
get timeout(): number;
|
|
40
|
+
set timeout(num: number);
|
|
41
|
+
private readonly _waitInfo;
|
|
42
|
+
protected _asyncTask(func: () => void | Promise<void>): void;
|
|
43
|
+
getPrototype(name: '_config'): types.IConfig;
|
|
44
|
+
getPrototype(name: '_sess'): session.Session | null;
|
|
45
|
+
getPrototype(name: '_headers'): http.IncomingHttpHeaders;
|
|
46
|
+
getPrototype(name: '_req'): http2.Http2ServerRequest | http.IncomingMessage;
|
|
47
|
+
getPrototype(name: '_res'): http2.Http2ServerResponse | http.ServerResponse;
|
|
48
|
+
getPrototype(name: '_socket'): lWs.Socket;
|
|
49
|
+
getPrototype(name: '_rawPost' | '_post' | '_get' | '_session'): Record<string, types.Json>;
|
|
50
|
+
getPrototype(name: '_input'): string;
|
|
51
|
+
getPrototype(name: string): types.Json;
|
|
52
|
+
setPrototype(name: string, val: string | string[] | http.IncomingHttpHeaders | Record<string, types.Json> | session.Session | lWs.Socket | null): void;
|
|
53
|
+
onLoad(): boolean | string | types.DbValue[] | Promise<boolean | string | types.DbValue[]>;
|
|
54
|
+
onUnload(rtn: boolean | string | types.DbValue[]): boolean | string | types.DbValue[] | Promise<boolean | string | types.DbValue[]>;
|
|
55
|
+
onUpgrade(): {
|
|
56
|
+
'headers'?: http.OutgoingHttpHeaders;
|
|
57
|
+
'timeout'?: number;
|
|
58
|
+
};
|
|
59
|
+
onData(data: Buffer | string, opcode: lWs.EOpcode): types.Json;
|
|
60
|
+
onMessage(data: Buffer | string, opcode: lWs.EOpcode): undefined | boolean | Promise<undefined | boolean>;
|
|
61
|
+
onDrain(): void | Promise<void>;
|
|
62
|
+
onClose(): void | Promise<void>;
|
|
63
|
+
protected _getRunTime(ms?: boolean): number;
|
|
64
|
+
protected _getMemoryUsage(): number;
|
|
65
|
+
protected _loadView(path: string, data?: types.Json): Promise<string>;
|
|
66
|
+
protected _checkInput(input: Record<string, types.Json>, rule: Record<string, types.Json[]>, rtn: types.Json[]): boolean;
|
|
67
|
+
protected _checkXInput(input: Record<string, types.Json>, rule: Record<string, types.Json[]>, rtn: types.Json[]): boolean;
|
|
68
|
+
protected _enabledXsrf(): void;
|
|
69
|
+
protected _getBasicAuth(user: string, pwd: string): string;
|
|
70
|
+
protected _device(): 'android' | 'windows' | 'linux' | 'macintosh' | 'ipad' | 'unknown';
|
|
71
|
+
private _authorization;
|
|
72
|
+
getAuthorization(): {
|
|
73
|
+
'user': string;
|
|
74
|
+
'pwd': string;
|
|
75
|
+
} | false | string;
|
|
76
|
+
protected _loadData(path: string): Promise<Record<string, string> | null>;
|
|
77
|
+
protected _location(location: string): false;
|
|
78
|
+
protected _startSession(link: db.Pool | kv.Pool, auth?: boolean, opt?: session.IOptions): Promise<void>;
|
|
79
|
+
protected _loadLocale(loc: string, pkg?: string): Promise<boolean>;
|
|
80
|
+
private _loadLocaleDeep;
|
|
81
|
+
protected _getLocaleJsonString(): string;
|
|
82
|
+
protected _getLocale(): string;
|
|
83
|
+
protected _cross(): boolean;
|
|
84
|
+
_l(key: string, data?: string[]): string;
|
|
85
|
+
protected _writeText(data: string): boolean;
|
|
86
|
+
protected _writeResult(data: types.Json): boolean;
|
|
87
|
+
protected _writeBinary(data: Buffer | string | Array<Buffer | string>): boolean;
|
|
88
|
+
protected _ping(): boolean;
|
|
89
|
+
protected _pong(): boolean;
|
|
90
|
+
protected _end(): void;
|
|
91
|
+
protected _handleFormData(events?: {
|
|
92
|
+
onfilestart?: (name: string) => boolean | undefined;
|
|
93
|
+
onfiledata?: (chunk: Buffer) => void;
|
|
94
|
+
onfileend?: () => void;
|
|
95
|
+
}): Promise<boolean>;
|
|
96
|
+
}
|
package/sys/master.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/sys/master.js
CHANGED
|
@@ -36,14 +36,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
const os = __importStar(require("os"));
|
|
37
37
|
const cluster = __importStar(require("cluster"));
|
|
38
38
|
const http = __importStar(require("http"));
|
|
39
|
-
const kebab = __importStar(require("
|
|
40
|
-
const sRoute = __importStar(require("
|
|
41
|
-
const lCore = __importStar(require("
|
|
42
|
-
const lFs = __importStar(require("
|
|
43
|
-
const lText = __importStar(require("
|
|
44
|
-
const lCrypto = __importStar(require("
|
|
45
|
-
const lTime = __importStar(require("
|
|
46
|
-
const lZip = __importStar(require("
|
|
39
|
+
const kebab = __importStar(require("../index"));
|
|
40
|
+
const sRoute = __importStar(require("../sys/route"));
|
|
41
|
+
const lCore = __importStar(require("../lib/core"));
|
|
42
|
+
const lFs = __importStar(require("../lib/fs"));
|
|
43
|
+
const lText = __importStar(require("../lib/text"));
|
|
44
|
+
const lCrypto = __importStar(require("../lib/crypto"));
|
|
45
|
+
const lTime = __importStar(require("../lib/time"));
|
|
46
|
+
const lZip = __importStar(require("../lib/zip"));
|
|
47
47
|
const workerList = {};
|
|
48
48
|
async function run() {
|
|
49
49
|
const configContent = await lFs.getContent(kebab.CONF_CWD + 'config.json', 'utf8');
|