cron listo
This commit is contained in:
+5
-3
@@ -22,9 +22,12 @@ import { CarreraModule } from './carrera/carrera.module';
|
||||
import { TipoEntradaModule } from './tipo-entrada/tipo-entrada.module';
|
||||
import { CarreraProgramaModule } from './carrera-programa/carrera-programa.module';
|
||||
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { BcryptModule } from './bcrypt/bcrypt.module';
|
||||
import { Carrera } from './carrera/entity/carrera.entity';
|
||||
import { CarreraPrograma } from './carrera-programa/entity/carrera-programa.entity';
|
||||
import { Carrito } from './carrito/entity/carrito.entity';
|
||||
import { CronModule } from './cron/cron.module';
|
||||
import { Dia } from './institucion-dia/entity/dia.entity';
|
||||
import { Equipo } from './equipo/entity/equipo.entity';
|
||||
import { EquipoTipoEntrada } from './equipo/entity/equipo-tipo-entrada.entity';
|
||||
@@ -44,10 +47,8 @@ import { Status } from './status/entity/status.entity';
|
||||
import { TipoCarrito } from './institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||
import { TipoEntrada } from './tipo-entrada/entity/tipo-entrada.entity';
|
||||
import { TipoUsuario } from './tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { Usuario } from './usuario/entity/usuario.entity';
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { BcryptModule } from './bcrypt/bcrypt.module';
|
||||
import { UploadFileModule } from './upload-file/upload-file.module';
|
||||
import { Usuario } from './usuario/entity/usuario.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -113,6 +114,7 @@ import { UploadFileModule } from './upload-file/upload-file.module';
|
||||
InstitucionTipoCarritoModule,
|
||||
BcryptModule,
|
||||
UploadFileModule,
|
||||
CronModule,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { CronController } from './cron.controller';
|
||||
|
||||
describe('CronController', () => {
|
||||
let controller: CronController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [CronController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<CronController>(CronController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
import { CronService } from './cron.service';
|
||||
|
||||
@Controller('cron')
|
||||
export class CronController {
|
||||
constructor(private cronService: CronService) {}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import { CronController } from './cron.controller';
|
||||
import { CronService } from './cron.service';
|
||||
|
||||
@Module({
|
||||
imports: [ScheduleModule.forRoot()],
|
||||
controllers: [CronController],
|
||||
providers: [CronService],
|
||||
})
|
||||
export class CronModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { CronService } from './cron.service';
|
||||
|
||||
describe('CronService', () => {
|
||||
let service: CronService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [CronService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<CronService>(CronService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Cron, SchedulerRegistry } from '@nestjs/schedule';
|
||||
// import { MultaService } from 'src/multa/multa.service';
|
||||
// import { UsuarioService } from 'src/usuario/usuario.service';
|
||||
|
||||
@Injectable()
|
||||
export class CronService {
|
||||
constructor(
|
||||
private schedulerRegistry: SchedulerRegistry,
|
||||
// private multaService: MultaService,
|
||||
// private usuarioService: UsuarioService,
|
||||
) {}
|
||||
|
||||
@Cron('0 6 * * * *', { name: 'multas' })
|
||||
revisarMultas() {}
|
||||
}
|
||||
Reference in New Issue
Block a user