0.1.1 • Published 2 years ago

xxl-job v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

XXL-JOB-NODEJS

NPM version

Provide xxl-job SDK for NodeJs.

TODO

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(9999, () => {
  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

0.1.1

2 years ago

0.1.0

2 years ago

0.0.0

2 years ago