import { Body , Controller , NotFoundException , Post } from '@nestjs/common' ; import { DalService } from '@notifire/dal' ; import { IUserEntity } from '@notifire/shared' ; import { ISeedDataResponseDto , SeedDataBodyDto } from './dtos/seed-data.dto' ; import { SeedData } from './usecases/seed-data/seed-data.usecase' ; import { SeedDataCommand } from './usecases/seed-data/seed-data.command' ; import { CreateSession } from './usecases/create-session/create-session.usecase' ; import { CreateSessionCommand } from './usecases/create-session/create-session.command' ; @ Controller ( '/testing' ) export class TestingController { constructor ( private seedDataUsecase , private dalService , private createSessionUsecase ) { } @ Post ( '/clear-db' ) async clearDB ( @ Body ( ) body ) { if ( process . env . NODE_ENV !== 'test' ) throw new NotFoundException ( ) ; await this . dalService . destroy ( ) ; return { ok : true , } ; } /**
     * Used for seeding data for client e2e tests,
     * Currently just creates a new user session and returns signed JWT
     */ @ Post ( '/session' ) async getSession ( @ Body ( ) body ) { if ( process . env . NODE_ENV !== 'test' ) throw new NotFoundException ( ) ; const command = CreateSessionCommand . create ( { } ) ; return await this . createSessionUsecase . execute ( command ) ; } @ Post ( '/seed' ) async seedData ( @ Body ( ) body ) { if ( process . env . NODE_ENV !== 'test' ) throw new NotFoundException ( ) ; const command = SeedDataCommand . create ( { } ) ; return await this . seedDataUsecase . execute ( command ) ; } }