xxl-job-nodejs
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

XXL-JOB-NODEJS

NPM version

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

License

MIT License © 2022 KeXing

Code Reference

xxl-job-executor-nodejs

Readme

Keywords

Package Sidebar

Install

npm i xxl-job-nodejs

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

26.3 kB

Total Files

6

Last publish

Collaborators

  • wangnew2013