Endpoint de test

This commit is contained in:
LeoMortari
2025-09-15 08:43:40 -03:00
parent a9f4ad1068
commit 853d49dd0b
6 changed files with 63 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import { VideosController } from './videos/videos.controller';
import { UsuariosModule } from './usuarios/usuarios.module';
import { LoggerMiddleware } from './middleware/logger.middleware';
import { RolesGuard } from './auth/roles.guard';
import { TestModule } from './test/test.module';
@Module({
imports: [
@@ -17,6 +18,7 @@ import { RolesGuard } from './auth/roles.guard';
VideosModule,
AuthModule,
UsuariosModule,
TestModule,
],
controllers: [AppController],
providers: [AppService, RolesGuard],

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TestController } from './test.controller';
describe('TestController', () => {
let controller: TestController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [TestController],
}).compile();
controller = module.get<TestController>(TestController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

View File

@@ -0,0 +1,12 @@
import { Controller, Get, Req } from '@nestjs/common';
import type { Request } from 'express';
@Controller('test')
export class TestController {
@Get()
debug(@Req() req: Request): string {
console.log('HEADERS:', req.headers);
return JSON.stringify(req.headers);
}
}

9
src/test/test.module.ts Normal file
View File

@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { TestController } from './test.controller';
import { TestService } from './test.service';
@Module({
controllers: [TestController],
providers: [TestService]
})
export class TestModule {}

View File

@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TestService } from './test.service';
describe('TestService', () => {
let service: TestService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [TestService],
}).compile();
service = module.get<TestService>(TestService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

4
src/test/test.service.ts Normal file
View File

@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class TestService {}