xxl-job-nodejs
v0.1.2
Published
Provide xxl-job SDK for NodeJs.
Downloads
4
Readme
XXL-JOB-NODEJS
Provide xxl-job SDK for NodeJs.
TODO
- [x] Example
- [x] 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}`)
})
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