mirror of
https://github.com/remnawave/node.git
synced 2026-05-17 14:06:41 +00:00
60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
import { ChannelCredentials } from 'nice-grpc';
|
|
import { experimental } from '@grpc/grpc-js';
|
|
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { Module } from '@nestjs/common';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
|
|
import { SupervisordNestjsModule } from '@remnawave/supervisord-nestjs';
|
|
import { XtlsSdkNestjsModule } from '@remnawave/xtls-sdk-nestjs';
|
|
|
|
import { JwtStrategy } from '@common/guards/jwt-guards/strategies/validate-token';
|
|
import { AbstractUdsResolver } from '@common/utils/unix-abstract.resolver';
|
|
import { validateEnvConfig } from '@common/utils/validate-env-config';
|
|
import { configSchema, Env } from '@common/config/app-config';
|
|
import { getJWTConfig } from '@common/config/jwt/jwt.config';
|
|
|
|
import { RemnawaveNodeModules } from './modules/remnawave-node.modules';
|
|
import { InternalModule } from './modules/internal/internal.module';
|
|
|
|
experimental.registerResolver('unix-abstract', AbstractUdsResolver);
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({
|
|
isGlobal: true,
|
|
envFilePath: '.env',
|
|
validate: (config) => validateEnvConfig<Env>(configSchema, config),
|
|
}),
|
|
XtlsSdkNestjsModule.forRootAsync({
|
|
imports: [],
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => {
|
|
return {
|
|
connectionUrl: `unix-abstract:///${configService.getOrThrow<string>('XTLS_API_SOCKET_PATH')}`,
|
|
credentials: ChannelCredentials.createInsecure(),
|
|
options: {
|
|
'grpc.max_receive_message_length': 100_000_000, // 100MB
|
|
},
|
|
};
|
|
},
|
|
}),
|
|
SupervisordNestjsModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (configService: ConfigService) => ({
|
|
connectionUrl: `http://unix:${configService.getOrThrow<string>('SUPERVISORD_SOCKET_PATH')}:/RPC2`,
|
|
options: {
|
|
username: configService.getOrThrow<string>('SUPERVISORD_USER'),
|
|
password: configService.getOrThrow<string>('SUPERVISORD_PASSWORD'),
|
|
},
|
|
}),
|
|
}),
|
|
RemnawaveNodeModules,
|
|
InternalModule,
|
|
JwtModule.registerAsync(getJWTConfig()),
|
|
],
|
|
providers: [JwtStrategy],
|
|
exports: [],
|
|
})
|
|
export class AppModule {}
|