Skip to content

Commit 190f74b

Browse files
authoredNov 7, 2024
Merge pull request #48 from tsrpcx/master
创建Server时,支持自定义CustomTypeSchema传入
2 parents 9ab96c3 + 39bc229 commit 190f74b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/server/base/BaseServer.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import chalk from "chalk";
22
import * as path from "path";
33
import { TSBuffer } from 'tsbuffer';
4+
import { CustomTypeSchema } from "tsbuffer-schema";
45
import { Counter, Flow, getCustomObjectIdTypes, MsgHandlerManager, MsgService, ParsedServerInput, ServiceMap, ServiceMapUtil, TransportDataUtil } from 'tsrpc-base-client';
56
import { ApiReturn, ApiServiceDef, BaseServiceType, Logger, LogLevel, ServerInputData, ServiceProto, setLogLevel, TsrpcError, TsrpcErrorType } from 'tsrpc-proto';
67
import { getClassObjectId } from "../../models/getClassObjectId";
@@ -170,7 +171,8 @@ export abstract class BaseServer<ServiceType extends BaseServiceType = BaseServi
170171
// Support mongodb/ObjectId
171172
...getCustomObjectIdTypes(getClassObjectId())
172173
}, {
173-
strictNullChecks: this.options.strictNullChecks
174+
strictNullChecks: this.options.strictNullChecks,
175+
customTypes: this.options.customTypes,
174176
});
175177
this.serviceMap = ServiceMapUtil.getServiceMap(proto);
176178
this.logger = this.options.logger;
@@ -967,6 +969,11 @@ export interface BaseServerOptions<ServiceType extends BaseServiceType> {
967969
* If `NODE_ENV` equals to `production`, the default value is `false`, otherwise is `true`.
968970
*/
969971
returnInnerError: boolean;
972+
973+
/**
974+
* Customize the protocol data type
975+
*/
976+
customTypes?: { [schemaId: string]: CustomTypeSchema }
970977
}
971978

972979
export const defaultBaseServerOptions: BaseServerOptions<any> = {

0 commit comments

Comments
 (0)
Please sign in to comment.