Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

xxl-job

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xxl-job

Provide xxl-job SDK for NodeJs.

latest
Source
npmnpm
Version
0.1.7
Version published
Weekly downloads
24
60%
Maintainers
1
Weekly downloads
 
Created
Source

XXL-JOB-NODEJS

NPM version

Provide xxl-job SDK for NodeJs.

TODO

  • Example
  • Complete basic functions
  • Koa support [low-priority]

Features

  • Job Execution
  • Log Query & Saved
  • Typescript Support
  • Express Integration
  • Run Request Params Support(broad cast…)

Install

npm install xxl-job

Usage

import express from 'express'
import type { JobHandler } from 'xxl-job'
import { createXxlJobExecutor } from 'xxl-job'

const jobHandlers = new Map<string, JobHandler>()

jobHandlers.set('nodejs_test', async (jobLogger, jobRequest, jobParams) => {
  jobLogger.warn(`request: ${JSON.stringify(jobRequest)}, params: ${jobParams}`)
})

jobHandlers.set('nodejs_test_with_Kill', async (jobLogger, jobRequest, jobParams) => {
  jobLogger.warn(`request: ${JSON.stringify(jobRequest)}, params: ${jobParams}`)
  const { isKill } = jobRequest
  for (let count = 1; count < 2000; count++) {
    // do something
    if (isKill())
      throw new Error('Job has been killed')
  }
})

const app = express()
app.use(express.json())

app.listen(8081, () => {
  const xxlJobExecutor = createXxlJobExecutor({
    app,
    jobHandlers,
    appType: 'express',
    accessToken: 'default_token',
    baseUrl: 'http://127.0.0.1:8081',
    // 若IP不固定可以使用<dynamicIP>占位符,程序会自动替换为当前IP
    // baseUrl: 'http://<dynamicIP>:8081',
    executorKey: 'executor-nodejs-express',
    scheduleCenterUrl: 'http://127.0.0.1:8080/xxl-job-admin', // xxl-job address
  })
  xxlJobExecutor.initialization()
})

See the example folder for details

License

MIT License © 2022 ikexing-cn

Code Reference

xxl-job-executor-nodejs

Keywords

xxljob

FAQs

Package last updated on 09 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts