1.0.1 • Published 6 months ago
@localzet/xtls-sdk-nestjs v1.0.1
Installation
npm install @localzet/xtls-sdk-nestjsQuick Start
Synchronous Configuration
import { XtlsSdkNestjsModule } from '@localzet/xtls-sdk-nestjs';
@Module({
imports: [
XtlsSdkNestjsModule.forRoot({
ip: 'your-ip-address',
port: 'your-port',
}),
],
})
export class AppModule {}Asynchronous Configuration
import { XtlsSdkNestjsModule } from '@localzet/xtls-sdk-nestjs';
@Module({
imports: [
XtlsSdkNestjsModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
ip: configService.get('XTLS_IP'),
port: configService.get('XTLS_PORT'),
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}Usage in Services
Use the @InjectXtls() decorator to inject the XTLS SDK instance into your services:
import { Injectable } from '@nestjs/common';
import { InjectXtls } from '@localzet/xtls-sdk-nestjs';
import { XtlsApi } from '@localzet/xtls-sdk';
@Injectable()
export class YourService {
constructor(@InjectXtls() private readonly xtlsApi: XtlsApi) {}
async yourMethod() {
// Use xtlsApi here
}
}Configuration Options
| Option | Type | Description |
|---|---|---|
| ip | string | The IP address for the XTLS connection |
| port | string | The port number for the XTLS connection |
API Reference
XtlsSdkNestjsModule
forRoot(options: XtlsModuleOptions): Static method for synchronous module configurationforRootAsync(options: AsyncModuleOptions): Static method for asynchronous module configuration
Decorators
@InjectXtls(): Decorator for injecting the XTLS SDK instance