1.0.6 • Published 1 month ago

expressweb-scheduler-ts v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

ExpressWebJs Scheduler Typescript Version

The software utility cron also known as cron job is a time-based job scheduler in computer operating systems. Users that set up and maintain software environments use cron to schedule jobs to run periodically at fixed times, dates, or intervals. ExpressWebJs Scheduler makes that really easy to achieve.

Getting started

  • First install expressweb-scheduler-ts
    npm install --save expressweb-scheduler-ts
  • Import Scheduler
import { Schedule } from "expressweb-scheduler-ts";
  • Schedule a command
Schedule.command("sendNewsletter").everySecond().run();
  • You can also run a closure function using the call method
Schedule.call(() => {
  console.log("this is a closure that is been run every seconds");
})
  .everySecond()
  .run();
  • You can also use the cron method:
Schedule.command("sendNewsletter").cron("* * * * * *").run();
Allowed fields in cron method

# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *

Allowed Values And Schedule Frequency Options

We've already seen a few examples of how you may configure a task to run at specified intervals. However, there are many more task schedule frequencies that you may assign to a task:

Visit ExpressWebJs Documentation site for more info.

ExpressWebJs is a powerful and flexible Node FrameWork for building efficient and scalable backend services for modern applications. It is designed to be easy to use and flexible, allowing you to build a wide range of backend services.

It includes support for enterprise-level features such as building multi-tenant systems, distributed systems, multi-threading, real-time events, queues, dependency injection, testing, and more. With ExpressWebJs, you can easily build efficient and reliable backend services that can handle a large volume of traffic and data.