npm install @localzet/xtls-sdk-nestjs
import { XtlsSdkNestjsModule } from '@localzet/xtls-sdk-nestjs';
@Module({
imports: [
XtlsSdkNestjsModule.forRoot({
ip: 'your-ip-address',
port: 'your-port',
}),
],
})
export class AppModule {}
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 {}
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
}
}
Option | Type | Description |
---|---|---|
ip | string | The IP address for the XTLS connection |
port | string | The port number for the XTLS connection |
-
forRoot(options: XtlsModuleOptions)
: Static method for synchronous module configuration -
forRootAsync(options: AsyncModuleOptions)
: Static method for asynchronous module configuration
-
@InjectXtls()
: Decorator for injecting the XTLS SDK instance