44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule } from '@nestjs/config';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { JwtModule } from '@nestjs/jwt';
|
|
import { PassportModule } from '@nestjs/passport';
|
|
import { DatabaseModule, TenantProvisioningService } from '@it0/database';
|
|
import { AuthController } from './interfaces/rest/controllers/auth.controller';
|
|
import { TenantController } from './interfaces/rest/controllers/tenant.controller';
|
|
import { JwtStrategy } from './infrastructure/strategies/jwt.strategy';
|
|
import { RbacGuard } from './infrastructure/guards/rbac.guard';
|
|
import { AuthService } from './application/services/auth.service';
|
|
import { UserRepository } from './infrastructure/repositories/user.repository';
|
|
import { ApiKeyRepository } from './infrastructure/repositories/api-key.repository';
|
|
import { User } from './domain/entities/user.entity';
|
|
import { Role } from './domain/entities/role.entity';
|
|
import { ApiKey } from './domain/entities/api-key.entity';
|
|
import { Tenant } from './domain/entities/tenant.entity';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({ isGlobal: true }),
|
|
DatabaseModule.forRoot(),
|
|
TypeOrmModule.forFeature([User, Role, ApiKey, Tenant]),
|
|
PassportModule.register({ defaultStrategy: 'jwt' }),
|
|
JwtModule.registerAsync({
|
|
useFactory: () => ({
|
|
secret: process.env.JWT_SECRET || 'dev-secret',
|
|
signOptions: { expiresIn: process.env.JWT_EXPIRES_IN || '24h' },
|
|
}),
|
|
}),
|
|
],
|
|
controllers: [AuthController, TenantController],
|
|
providers: [
|
|
JwtStrategy,
|
|
RbacGuard,
|
|
AuthService,
|
|
UserRepository,
|
|
ApiKeyRepository,
|
|
TenantProvisioningService,
|
|
],
|
|
exports: [AuthService],
|
|
})
|
|
export class AuthModule {}
|