@onlynices/nest-centrifuge
v1.0.6
Published
# nest-centrifuge
Readme
NestJS Centrifuge integration module using cent.js
nest-centrifuge
Install
npm install @onlynices/nest-centrifugeHow To use
import { CentrifugeAuthService, CentrifugeClient, CENTRIFUGE_CLIENT } from '@onlynices/nest-centrifuge';
import { Inject } from '@nestjs/common';
@Injectable()
export class AppService {
constructor(
@Inject(CENTRIFUGE_CLIENT)
private readonly centrifugeClient: CentrifugeClient,
private readonly centrifugeAuthService: CentrifugeAuthService
) {}
async createAuthToken(userId: number) {
const token = await this.centrifugeAuthService.generateUserToken(userId.toString(), ['chat']);
return token;
}
async getChannels() {
const channels = await this.centrifugeClient.channels({ pattern: "*" });
return channels;
}
// ...
}Hint : methods args without any request parameters need to pass {}
