index.ts 556 B

123456789101112131415161718192021
  1. import express from "express";
  2. import { CronsService, SchedulerRegistry } from "./crons.service";
  3. import { collectionsService } from "../collections";
  4. const router = express.Router();
  5. const schedulerRegistry = new SchedulerRegistry([]);
  6. const cronsService = new CronsService(collectionsService, schedulerRegistry);
  7. router.put("/", async (req, res, next) => {
  8. const cronData = req.body;
  9. try {
  10. const result = await cronsService.toggleCronJobByName(cronData);
  11. res.send(result);
  12. } catch (error) {
  13. next(error);
  14. }
  15. });
  16. export { router };