cron listo
This commit is contained in:
@@ -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