@domain.js/main 0.4.5 → 0.4.7
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.
|
@@ -21,7 +21,7 @@ export declare function Main(cnf: Cnf, deps: Deps): Readonly<{
|
|
|
21
21
|
auto: <F extends (...args: any[]) => any>(fn: F, schema: Schema[], errorFn: Function, extra: any) => (...args: Parameters<F>) => ReturnType<F>;
|
|
22
22
|
validate: (schema: Schema, data: any) => boolean;
|
|
23
23
|
compile: (schema: Schema) => ajv.ValidateFunction<unknown>;
|
|
24
|
-
/**
|
|
24
|
+
/** instance of Ajv */
|
|
25
25
|
ajv: import("ajv").default;
|
|
26
26
|
}>;
|
|
27
27
|
export declare const Deps: string[];
|
package/dist/http/index.d.ts
CHANGED
package/dist/http/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const socket_1 = require("./socket");
|
|
|
27
27
|
const utils_1 = require("./utils");
|
|
28
28
|
function Main(cnf, deps) {
|
|
29
29
|
const utils = (0, utils_1.Utils)(cnf);
|
|
30
|
-
const { routers, domain, httpCodes, makeProfileHook } = deps;
|
|
30
|
+
const { routers, domain, httpCodes, makeProfileHook, socketLogger } = deps;
|
|
31
31
|
const server = restify.createServer();
|
|
32
32
|
server.use(restify.plugins.queryParser());
|
|
33
33
|
server.use(restify.plugins.bodyParser({
|
|
@@ -46,6 +46,24 @@ function Main(cnf, deps) {
|
|
|
46
46
|
// 根据需求起送socket服务
|
|
47
47
|
if (cnf.socket) {
|
|
48
48
|
const io = new socket_io_1.Server(server);
|
|
49
|
+
// 处理日志
|
|
50
|
+
if (socketLogger) {
|
|
51
|
+
io.on("connection", (socket) => {
|
|
52
|
+
const { emit } = socket;
|
|
53
|
+
socket.emit = (...args) => {
|
|
54
|
+
socketLogger("emit", socket.id, args);
|
|
55
|
+
return emit.apply(socket, args);
|
|
56
|
+
};
|
|
57
|
+
socketLogger("connection", socket.id);
|
|
58
|
+
socket.use((args, next) => {
|
|
59
|
+
next();
|
|
60
|
+
socketLogger("use", socket.id, args);
|
|
61
|
+
});
|
|
62
|
+
socket.on("disconnect", (reason) => {
|
|
63
|
+
socketLogger("disconnect", socket.id, reason);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
49
67
|
(0, socket_1.BridgeSocket)(io, domain);
|
|
50
68
|
}
|
|
51
69
|
// Http server start
|
package/dist/http/socket.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** 将 readonly string[] 转换成联合类型 */
|
|
2
2
|
export declare type ReadonlyArray2union<T extends ReadonlyArray<any>> = T extends ReadonlyArray<infer A> ? A : never;
|
|
3
|
+
declare type Type = "string" | "number" | "integer" | "object" | "array" | "boolean";
|
|
3
4
|
/** 接口参数 schema 定义的类型 */
|
|
4
5
|
export interface ParamsSchema<Params extends {}, Keys extends string | number | symbol = keyof Params> {
|
|
5
6
|
/** 接口整体描述信息 */
|
|
@@ -17,6 +18,7 @@ export interface ParamsSchema<Params extends {}, Keys extends string | number |
|
|
|
17
18
|
/** 当前参数的描述信息 */
|
|
18
19
|
description: string;
|
|
19
20
|
/** 当前参数的类型 */
|
|
20
|
-
type:
|
|
21
|
+
type: Type | [Type];
|
|
21
22
|
}>;
|
|
22
23
|
}
|
|
24
|
+
export {};
|