Provide xxl-job SDK for NodeJs.
- Example
- Complete basic functions
- Koa support [low-priority]
- Job Execution
- Log Query & Saved
- Typescript Support
- Express Integration
- Run Request Params Support(broad cast…)
npm install xxl-job
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}`)
})
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', // Server address
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