@qiwi/nestjs-enterprise-thrift

thrift module for nestjs enterprise

Usage no npm install needed!

<script type="module">
  import qiwiNestjsEnterpriseThrift from 'https://cdn.skypack.dev/@qiwi/nestjs-enterprise-thrift';
</script>

README

@qiwi/nestjs-enterprise-thrift"

Nestjs module for working with Apache Thrift

Installation

Requires following packages to be installed

yarn add @qiwi/nestjs-enterprise-thrift

Configuration

Imports

import { Module } from '@nestjs/common'
import { ConnectionProviderModule } from '@qiwi/nestjs-enterprise-connection-provider'
import { LoggerModule } from '@qiwi/nestjs-enterprise-logger-nestjs'
import { ConsulModule } from '@qiwi/nestjs-enterprise-consul-nestjs'
import { ConfigModule } from '@qiwi/nestjs-enterprise-config-nestjs'
import { ThriftModule } from '@qiwi/nestjs-enterprise-thrift'

@Module({
  imports: [
    ConfigModule,
    LoggerModule,
    ConsulModule,
    ConnectionProviderModule,
    // and so on
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

Usage

@Injectable()
class AuthService {
  client?: Client
  creds?: TCredentials
  token?: TAuthentication

  @Inject('IConfigService')
  config: IConfig

  @Inject('IThriftClientService')
  thrift: IThriftClientService

    getClient() {
        const serviceProfile: IServiceDeclaration = this.config.get('serviceName')
        this.client = this.thrift.getClient(serviceProfile, Client, {
            multiplexer: false,
            connectionOpts: {
                transport: thrift.TBufferedTransport,
                protocol: thrift.TBinaryProtocol,
            },
        })
        return this.client
    }
  }
}

Decorators

@ThriftServer

    @ThriftServer(CalculatorProcessor, 9091)
    class TestServer {
      ping(result: () => void) {
        result()
      }

      add(n1: any, n2: any, result: (arg0: null, arg1: any) => void) {
        result(null, n1 + n2)
      }
    }

API

Class ConnectionProviderModule

Exports IThriftClientService with token IThriftClientService