Вам просто нужно создать экземпляр клиента jayson, а затем использовать его, ничего более:
'use strict';
const jayson = require('./../..');
// create a client
const client = jayson.client.http({
port: 3000
});
// invoke "add"
client.request('add', [1, 1], function(err, response) {
if(err) throw err;
console.log(response.result); // 2
});
Если, однако, ваш вопрос состоит в том, как обслуживать jayson из nest.js, вы можете добавить сервер jayson в качестве промежуточного программного обеспечения, вот пример фиктивного (машинописного):
export class AppModule implements NestModule {
public configure(consumer: MiddlewareConsumer): void {
const rpcTestServer: Server = new Server({
test: (args, callback) => {
callback(null, 'hello');
},
});
consumer
.apply(rpcTestServer.middleware())
.forRoutes({ path: '*', method: RequestMethod.ALL });
}
}