Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

创建Server时,支持自定义CustomTypeSchema传入 #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/server/base/BaseServer.ts
@@ -1,6 +1,7 @@
import chalk from "chalk";
import * as path from "path";
import { TSBuffer } from 'tsbuffer';
import { CustomTypeSchema } from "tsbuffer-schema";
import { Counter, Flow, getCustomObjectIdTypes, MsgHandlerManager, MsgService, ParsedServerInput, ServiceMap, ServiceMapUtil, TransportDataUtil } from 'tsrpc-base-client';
import { ApiReturn, ApiServiceDef, BaseServiceType, Logger, LogLevel, ServerInputData, ServiceProto, setLogLevel, TsrpcError, TsrpcErrorType } from 'tsrpc-proto';
import { getClassObjectId } from "../../models/getClassObjectId";
Expand Down Expand Up @@ -170,7 +171,8 @@ export abstract class BaseServer<ServiceType extends BaseServiceType = BaseServi
// Support mongodb/ObjectId
...getCustomObjectIdTypes(getClassObjectId())
}, {
strictNullChecks: this.options.strictNullChecks
strictNullChecks: this.options.strictNullChecks,
customTypes: this.options.customTypes,
});
this.serviceMap = ServiceMapUtil.getServiceMap(proto);
this.logger = this.options.logger;
Expand Down Expand Up @@ -967,6 +969,11 @@ export interface BaseServerOptions<ServiceType extends BaseServiceType> {
* If `NODE_ENV` equals to `production`, the default value is `false`, otherwise is `true`.
*/
returnInnerError: boolean;

/**
* Customize the protocol data type
*/
customTypes?: { [schemaId: string]: CustomTypeSchema }
}

export const defaultBaseServerOptions: BaseServerOptions<any> = {
Expand Down