feat: 修改parseRequest为可异步(加密库需要异步),新增getCorsExposeHeaders用于注册跨域header,新增registerCustomAspect用于注册自定义aspect(connector前后台初始化逻辑)
This commit is contained in:
parent
16f4bec1d3
commit
8adf31af12
|
|
@ -3,6 +3,7 @@ import { SyncContext } from "../store/SyncRowStore";
|
|||
import { EntityDict, OpRecord } from "./Entity";
|
||||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { OakException } from "./Exception";
|
||||
type Promisable<T> = T | Promise<T>;
|
||||
export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>> {
|
||||
callAspect: (name: string, params: any, context?: FrontCxt) => Promise<{
|
||||
result: any;
|
||||
|
|
@ -10,11 +11,11 @@ export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt exte
|
|||
message?: string | null;
|
||||
}>;
|
||||
getRouter: () => string;
|
||||
parseRequest: (headers: IncomingHttpHeaders, body?: any, files?: any) => {
|
||||
parseRequest: (headers: IncomingHttpHeaders, body?: any, files?: any) => Promisable<{
|
||||
contextString?: string;
|
||||
aspectName: string;
|
||||
data?: any;
|
||||
};
|
||||
}>;
|
||||
serializeResult: (result: any, opRecords: OpRecord<ED>[], headers: IncomingHttpHeaders, body: any, message?: string) => Promise<{
|
||||
body: any;
|
||||
headers?: Record<string, any>;
|
||||
|
|
@ -43,4 +44,18 @@ export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt exte
|
|||
[T in keyof ED]?: ED[T]['OpSchema'][];
|
||||
}>;
|
||||
getCorsHeader: () => string[];
|
||||
getCorsExposeHeaders?: () => string[];
|
||||
registerCustomAspect?: () => {
|
||||
name: string;
|
||||
handler: (params: {
|
||||
headers?: IncomingHttpHeaders;
|
||||
contextString?: string;
|
||||
params?: any;
|
||||
}) => Promise<{
|
||||
result: any;
|
||||
opRecords?: OpRecord<ED>[];
|
||||
message?: string;
|
||||
}>;
|
||||
}[];
|
||||
}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import { IncomingHttpHeaders } from "http";
|
||||
import { IncomingHttpHeaders, IncomingMessage } from "http";
|
||||
import { SyncContext } from "../store/SyncRowStore";
|
||||
import { EntityDict, OpRecord } from "./Entity";
|
||||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { OakException } from "./Exception";
|
||||
|
||||
type Promisable<T> = T | Promise<T>;
|
||||
|
||||
export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>> {
|
||||
callAspect: (
|
||||
name: string,
|
||||
|
|
@ -17,11 +19,11 @@ export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt exte
|
|||
|
||||
getRouter: () => string;
|
||||
|
||||
parseRequest: (headers: IncomingHttpHeaders, body?: any, files?: any) => {
|
||||
parseRequest: (headers: IncomingHttpHeaders, body?: any, files?: any) => Promisable<{
|
||||
contextString?: string;
|
||||
aspectName: string;
|
||||
data?: any;
|
||||
};
|
||||
}>;
|
||||
|
||||
serializeResult: (
|
||||
result: any,
|
||||
|
|
@ -72,4 +74,21 @@ export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt exte
|
|||
}>
|
||||
|
||||
getCorsHeader: () => string[];
|
||||
getCorsExposeHeaders?: () => string[];
|
||||
|
||||
// 注册自定义端点
|
||||
registerCustomAspect?: () => {
|
||||
name: string;
|
||||
handler: (
|
||||
params: {
|
||||
headers?: IncomingHttpHeaders;
|
||||
contextString?: string,
|
||||
params?: any
|
||||
}
|
||||
) => Promise<{
|
||||
result: any;
|
||||
opRecords?: OpRecord<ED>[];
|
||||
message?: string;
|
||||
}>;
|
||||
}[];
|
||||
}
|
||||
Loading…
Reference in New Issue