1.0.22 • Published 11 months ago

@enschedule/hub v1.0.22

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

worker

Docker

Environment variables

DB_USER DB_HOST DB_PASSWORD DB_DATABASE DB_PORT ENSCHEDULE_API REGISTER_JOBS_SCRIPT ENSCHEDULE_API_PORT or default is 8080 ENSCHEDULE_API_HOSTNAME or undefined

Usage

Use the image as is:

cat <<EOC > index.js
const { z } = require('zod');

module.exports = async (worker) => {
  worker.registerJob({
      id: 'log-job',
      title: 'Log message',
      dataSchema: z.object({
          message: z.string(),
      }),
      job: async (data, console) => {
          console.log(data.message);
      },
      description: 'Will print the message on the server',
      example: {
          message: 'some message',
      },
  });
}

EOC
docker container run -p 8080:8080 -e API_ENDPOINT=true -v ${PWD}:/enschedule/jobs enschedule:latest

API

Usage

import { Worker } from '@enschedule/worker';
const worker = new Worker({});
void (async () => {
  worker.registerJob({
    id: 'log-job',
    title: 'Log message',
    dataSchema: z.object({
        message: z.string(),
    }),
    job: async (data, console) => {
        console.log(data.message);
    },
    description: 'Will print the message on the server',
    example: {
        message: 'some message',
    },
  });
  await worker.startPolling();
  if (process.env.ENSCHEDULE_API) {
      worker.serve({ port: 8080 }).listern();
  }
})();
1.0.19

11 months ago

1.0.2

1 year ago

1.0.18

11 months ago

1.0.1

1 year ago

1.0.17

11 months ago

1.0.0

1 year ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.22

11 months ago

1.0.21

11 months ago

1.0.10

11 months ago

1.0.20

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

0.0.1

1 year ago