cron listo
This commit is contained in:
parent
08ae09f2d7
commit
dea010ac34
59
package-lock.json
generated
59
package-lock.json
generated
@ -15,6 +15,7 @@
|
||||
"@nestjs/jwt": "^8.0.0",
|
||||
"@nestjs/passport": "^8.2.1",
|
||||
"@nestjs/platform-express": "^8.0.0",
|
||||
"@nestjs/schedule": "^1.1.0",
|
||||
"@nestjs/typeorm": "^8.0.3",
|
||||
"bcrypt": "^5.0.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
@ -1537,6 +1538,20 @@
|
||||
"@nestjs/core": "^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/schedule": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schedule/-/schedule-1.1.0.tgz",
|
||||
"integrity": "sha512-0QpbwClUildXqlyoaygG+aIQZNNMv31XDyQxX+Ob1zw/3I8+AVrDlBwZHQ+tlhIcJFR8aG+VTH8xwIjXwtS1UA==",
|
||||
"dependencies": {
|
||||
"cron": "1.8.2",
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^6.10.11 || ^7.0.0 || ^8.0.0",
|
||||
"@nestjs/core": "^7.0.0 || ^8.0.0",
|
||||
"reflect-metadata": "^0.1.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/schematics": {
|
||||
"version": "8.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-8.0.8.tgz",
|
||||
@ -3556,6 +3571,14 @@
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cron": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
|
||||
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
|
||||
"dependencies": {
|
||||
"moment-timezone": "^0.5.x"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -6896,6 +6919,17 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"dependencies": {
|
||||
"moment": ">= 2.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
@ -10869,6 +10903,15 @@
|
||||
"tslib": "2.3.1"
|
||||
}
|
||||
},
|
||||
"@nestjs/schedule": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schedule/-/schedule-1.1.0.tgz",
|
||||
"integrity": "sha512-0QpbwClUildXqlyoaygG+aIQZNNMv31XDyQxX+Ob1zw/3I8+AVrDlBwZHQ+tlhIcJFR8aG+VTH8xwIjXwtS1UA==",
|
||||
"requires": {
|
||||
"cron": "1.8.2",
|
||||
"uuid": "8.3.2"
|
||||
}
|
||||
},
|
||||
"@nestjs/schematics": {
|
||||
"version": "8.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-8.0.8.tgz",
|
||||
@ -12460,6 +12503,14 @@
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cron": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cron/-/cron-1.8.2.tgz",
|
||||
"integrity": "sha512-Gk2c4y6xKEO8FSAUTklqtfSr7oTq0CiPQeLBG5Fl0qoXpZyMcj1SG59YL+hqq04bu6/IuEA7lMkYDAplQNKkyg==",
|
||||
"requires": {
|
||||
"moment-timezone": "^0.5.x"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
@ -15009,6 +15060,14 @@
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",
|
||||
"integrity": "sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw=="
|
||||
},
|
||||
"moment-timezone": {
|
||||
"version": "0.5.34",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.34.tgz",
|
||||
"integrity": "sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg==",
|
||||
"requires": {
|
||||
"moment": ">= 2.9.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
|
@ -27,6 +27,7 @@
|
||||
"@nestjs/jwt": "^8.0.0",
|
||||
"@nestjs/passport": "^8.2.1",
|
||||
"@nestjs/platform-express": "^8.0.0",
|
||||
"@nestjs/schedule": "^1.1.0",
|
||||
"@nestjs/typeorm": "^8.0.3",
|
||||
"bcrypt": "^5.0.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
|
@ -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 {}
|
||||
|
18
src/cron/cron.controller.spec.ts
Normal file
18
src/cron/cron.controller.spec.ts
Normal file
@ -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();
|
||||
});
|
||||
});
|
7
src/cron/cron.controller.ts
Normal file
7
src/cron/cron.controller.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
import { CronService } from './cron.service';
|
||||
|
||||
@Controller('cron')
|
||||
export class CronController {
|
||||
constructor(private cronService: CronService) {}
|
||||
}
|
11
src/cron/cron.module.ts
Normal file
11
src/cron/cron.module.ts
Normal file
@ -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 {}
|
18
src/cron/cron.service.spec.ts
Normal file
18
src/cron/cron.service.spec.ts
Normal file
@ -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();
|
||||
});
|
||||
});
|
16
src/cron/cron.service.ts
Normal file
16
src/cron/cron.service.ts
Normal file
@ -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() {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user