import { Application, ChannelService, HandlerService, } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts'; import { mongoose } from '@typegoose/typegoose'; const { ObjectId } = mongoose.Types; export default function (app: Application) { new HandlerService(app, {}); return new GMRemote(app); } // rpc 定义挪到单独的定义文件(user.rpc.define.ts)。解决ts-node 有可能找不到定义的问题。 // 你也可以用其它方法解决,或者没有遇到过这个问题的话,定义还是可以放在这里。 // UserRpc的命名空间自动合并 // declare global { // interface UserRpc { // chat: { // GMRemote: RemoterClass; // }; // } // } export class GMRemote { constructor(private app: Application) { this.app = app; this.channelService = app.get('channelService'); } private channelService: ChannelService; }