@outloud/adonis-scheduler 1.0.7 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,19 +1,15 @@
1
- <div align="center">
2
- <h2><b>Adonis Scheduler</b></h2>
3
-
4
- <p>
1
+ # AdonisJS Scheduler
5
2
 
6
- `@outloud/adonis-scheduler` is a cron job scheduler for [AdonisJS](https://adonisjs.com/).
3
+ Cron job scheduler for [AdonisJS](https://adonisjs.com/) 6/7.
7
4
 
8
- </p>
9
- </div>
5
+ <p>
10
6
 
7
+ [![typescript-image]][typescript-url]
8
+ [![npm-image]][npm-url]
9
+ [![npm-download-image]][npm-download-url]
10
+ [![license-image]][license-url]
11
11
 
12
- <div align="center">
13
-
14
- [![npm-image]][npm-url] [![license-image]][license-url]
15
-
16
- </div>
12
+ </p>
17
13
 
18
14
  ---
19
15
  ## Features
@@ -60,9 +56,16 @@ export default class TestTask extends Task {
60
56
  ### Register a task
61
57
  For task to run it must be registered in the scheduler.
62
58
 
63
- > [!NOTE]
64
- > By default tasks are auto-discovered using the locations defined in config.
59
+ #### Auto-discovery (recommended)
60
+ By default tasks are auto-discovered using the locations defined in `config/scheduler.ts`.
65
61
 
62
+ ```ts
63
+ const schedulerConfig = defineConfig({
64
+ locations: ['./app/**/*.task.js'],
65
+ })
66
+ ```
67
+
68
+ #### Manual registration
66
69
  If you want to register tasks manually, you can register tasks in two ways: using the `start/scheduler.ts` preloaded file or in a provider's `start` method.
67
70
 
68
71
  Using `start/scheduler.ts` file.
@@ -73,7 +76,7 @@ import scheduler from '@outloud/adonis-scheduler/services/main'
73
76
  scheduler.register(() => import('../app/tasks/test.task.js'))
74
77
  ```
75
78
 
76
- Or using a provider.
79
+ Or in a any provider's `start` method.
77
80
 
78
81
  ```ts
79
82
  import type { ApplicationService } from '@adonisjs/core/types'
@@ -116,6 +119,71 @@ To run it as part of the **HTTP server**, set following env variable:
116
119
  SCHEDULER_HTTP_SERVER=true
117
120
  ```
118
121
 
122
+ You can also create a custom worker command that runs the scheduler. This is useful if you want to add health checks or run other logic with the scheduler.
123
+
124
+ ```ts [commands/worker.ts]
125
+ import { createServer, type Server as HttpServer } from 'node:http'
126
+ import { BaseCommand } from '@adonisjs/core/ace'
127
+ import type { CommandOptions } from '@adonisjs/core/types/ace'
128
+ import { inject } from '@adonisjs/core'
129
+ import { Scheduler } from '@outloud/adonis-scheduler'
130
+
131
+ export default class extends BaseCommand {
132
+ static commandName = 'worker'
133
+ static description = 'Run a worker process.'
134
+
135
+ static options: CommandOptions = {
136
+ startApp: true,
137
+ staysAlive: true,
138
+ }
139
+
140
+ private server?: HttpServer
141
+ private scheduler?: Scheduler
142
+
143
+ prepare() {
144
+ this.app.terminating(() => {
145
+ this.server?.close()
146
+ })
147
+ this.app.terminating(() => this.scheduler?.stop())
148
+ }
149
+
150
+ @inject()
151
+ async run(scheduler: Scheduler): Promise<void> {
152
+ this.scheduler = scheduler
153
+
154
+ await Promise.all([
155
+ this.startServer(),
156
+ this.scheduler.start(true),
157
+ ])
158
+ }
159
+
160
+ private async startServer() {
161
+ const server = await this.makeServer()
162
+ await server.boot()
163
+
164
+ const httpServer = createServer(server.handle.bind(server))
165
+ server.setNodeServer(httpServer)
166
+ this.server = httpServer
167
+
168
+ const host = process.env.HOST || '0.0.0.0'
169
+ const port = Number(process.env.PORT || 3000)
170
+
171
+ httpServer.once('listening', () => this.logger.info(`listening to http server, host: ${host}, port: ${port}`))
172
+
173
+ return httpServer.listen(port, host)
174
+ }
175
+
176
+ private async makeServer() {
177
+ const server = await this.app.container.make('server')
178
+ const router = server.getRouter()
179
+
180
+ router.get('/health', () => ({ status: 'ok' }))
181
+
182
+ return server
183
+ }
184
+ }
185
+ ```
186
+
119
187
  ## Locking
120
188
 
121
189
  > [!NOTE]
@@ -162,20 +230,37 @@ export default class TestTask extends Task {
162
230
 
163
231
  It's possible to globally handle errors for all your tasks or define custom error handler for each task.
164
232
 
233
+ ### Global error handler
234
+
165
235
  To register global error handler, you can use the `onError` method of the scheduler service. You can define it in `start/scheduler.ts` preloaded file.
166
236
  This handler will run only if custom error handler is not defined in the task itself.
167
237
 
168
238
  ```ts
169
239
  import logger from '@adonisjs/core/services/logger'
170
240
  import scheduler from '@outloud/adonis-scheduler/services/main'
171
- import { Sentry } from '@rlanz/sentry'
172
241
 
173
242
  scheduler.onError((error, task) => {
174
243
  logger.error(error)
175
- Sentry.captureException(error)
176
244
  })
177
245
  ```
178
246
 
247
+ Or you can listen to `scheduler:error` event using emitter.
248
+
249
+ ```ts
250
+ import emitter from '@adonisjs/core/services/emitter'
251
+ import logger from '@adonisjs/core/services/logger'
252
+
253
+ emitter.on('scheduler:error', ({ error, task }) => {
254
+ logger.error(error)
255
+ })
256
+ ```
257
+
258
+ > [!WARNING]
259
+ > When you register global error handler, the package will not throw any errors and it's your responsibility to log or handle them in the handler.
260
+ > If you don't register global error handler, the package will throw error and exit.
261
+
262
+ ### Task-level error handler
263
+
179
264
  Custom error handler can be defined in the task itself by implementing `onError` method.
180
265
 
181
266
  ```ts
@@ -188,8 +273,14 @@ export default class TestTask extends Task {
188
273
  }
189
274
  ```
190
275
 
191
- [npm-image]: https://img.shields.io/npm/v/@outloud/adonis-scheduler.svg?style=for-the-badge&logo=**npm**
276
+ [npm-image]: https://badgen.net/npm/v/@outloud/adonis-scheduler/latest
192
277
  [npm-url]: https://npmjs.org/package/@outloud/adonis-scheduler "npm"
193
278
 
194
- [license-image]: https://img.shields.io/npm/l/@outloud/adonis-scheduler?color=blueviolet&style=for-the-badge
195
- [license-url]: LICENSE "license"
279
+ [npm-download-image]: https://badgen.net/npm/dm/@outloud/adonis-scheduler
280
+ [npm-download-url]: https://npmcharts.com/compare/@outloud/adonis-scheduler?minimal=true "downloads"
281
+
282
+ [typescript-image]: https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white
283
+ [typescript-url]: https://www.typescriptlang.org "TypeScript"
284
+
285
+ [license-image]: https://img.shields.io/npm/l/@outloud/adonis-scheduler.svg?sanitize=true
286
+ [license-url]: LICENSE.md "license"
@@ -0,0 +1,10 @@
1
+ //#region \0@oxc-project+runtime@0.114.0/helpers/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+
9
+ //#endregion
10
+ export { __decorate };
@@ -0,0 +1,7 @@
1
+ //#region \0@oxc-project+runtime@0.114.0/helpers/decorateMetadata.js
2
+ function __decorateMetadata(k, v) {
3
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
+ }
5
+
6
+ //#endregion
7
+ export { __decorateMetadata };
@@ -1,18 +1,19 @@
1
- import { BaseCommand } from '@adonisjs/core/ace';
2
- import { CommandOptions } from '@adonisjs/core/types/ace';
1
+ import { BaseCommand } from "@adonisjs/core/ace";
2
+ import { CommandOptions } from "@adonisjs/core/types/ace";
3
3
 
4
+ //#region commands/make_task.d.ts
4
5
  declare class MakeTask extends BaseCommand {
5
- static commandName: string;
6
- static description: string;
7
- static options: CommandOptions;
8
- /**
9
- * The name of the job file.
10
- */
11
- name: string;
12
- /**
13
- * Execute command
14
- */
15
- run(): Promise<void>;
6
+ static commandName: string;
7
+ static description: string;
8
+ static options: CommandOptions;
9
+ /**
10
+ * The name of the job file.
11
+ */
12
+ name: string;
13
+ /**
14
+ * Execute command
15
+ */
16
+ run(): Promise<void>;
16
17
  }
17
-
18
- export { MakeTask as default };
18
+ //#endregion
19
+ export { MakeTask as default };
@@ -1,42 +1,20 @@
1
- import { __name } from '../chunk-SHUYVCID.js';
2
- import 'reflect-metadata';
3
- import { BaseCommand, args } from '@adonisjs/core/ace';
1
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.114.0/helpers/decorateMetadata.js";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.114.0/helpers/decorate.js";
3
+ import { BaseCommand, args } from "@adonisjs/core/ace";
4
4
 
5
- function _ts_decorate(decorators, target, key, desc) {
6
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
- return c > 3 && r && Object.defineProperty(target, key, r), r;
10
- }
11
- __name(_ts_decorate, "_ts_decorate");
12
- function _ts_metadata(k, v) {
13
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
14
- }
15
- __name(_ts_metadata, "_ts_metadata");
5
+ //#region commands/make_task.ts
16
6
  var MakeTask = class extends BaseCommand {
17
- static {
18
- __name(this, "MakeTask");
19
- }
20
- static commandName = "make:task";
21
- static description = "Make a new task class";
22
- static options = {
23
- allowUnknownFlags: true
24
- };
25
- /**
26
- * Execute command
27
- */
28
- async run() {
29
- const codemods = await this.createCodemods();
30
- await codemods.makeUsingStub(import.meta.dirname + "/../stubs", "command/task.stub", {
31
- entity: this.app.generators.createEntity(this.name)
32
- });
33
- }
7
+ static commandName = "make:task";
8
+ static description = "Make a new task class";
9
+ static options = { allowUnknownFlags: true };
10
+ /**
11
+ * Execute command
12
+ */
13
+ async run() {
14
+ await (await this.createCodemods()).makeUsingStub(import.meta.dirname + "/../stubs", "command/task.stub", { entity: this.app.generators.createEntity(this.name) });
15
+ }
34
16
  };
35
- _ts_decorate([
36
- args.string({
37
- description: "Name of the task"
38
- }),
39
- _ts_metadata("design:type", String)
40
- ], MakeTask.prototype, "name", void 0);
17
+ __decorate([args.string({ description: "Name of the task" }), __decorateMetadata("design:type", String)], MakeTask.prototype, "name", void 0);
41
18
 
42
- export { MakeTask as default };
19
+ //#endregion
20
+ export { MakeTask as default };
@@ -1,19 +1,15 @@
1
- import { BaseCommand } from '@adonisjs/core/ace';
2
- import { CommandOptions } from '@adonisjs/core/types/ace';
3
- import { a as Scheduler } from '../scheduler-vBDqaysB.js';
4
- import '@adonisjs/core/container';
5
- import '@adonisjs/core/types';
6
- import '@adonisjs/lock/types';
7
- import '@adonisjs/core/logger';
8
- import '@adonisjs/core/events';
1
+ import { Scheduler } from "../src/scheduler.js";
2
+ import { BaseCommand } from "@adonisjs/core/ace";
3
+ import { CommandOptions } from "@adonisjs/core/types/ace";
9
4
 
5
+ //#region commands/scheduler_run.d.ts
10
6
  declare class SchedulerRun extends BaseCommand {
11
- static commandName: string;
12
- static description: string;
13
- static options: CommandOptions;
14
- private scheduler?;
15
- prepare(): void;
16
- run(scheduler: Scheduler): Promise<void>;
7
+ static commandName: string;
8
+ static description: string;
9
+ static options: CommandOptions;
10
+ private scheduler?;
11
+ prepare(): void;
12
+ run(scheduler: Scheduler): Promise<void>;
17
13
  }
18
-
19
- export { SchedulerRun as default };
14
+ //#endregion
15
+ export { SchedulerRun as default };
@@ -1,47 +1,33 @@
1
- import { Scheduler } from '../chunk-6VW5PUDE.js';
2
- import '../chunk-OIXFFNQU.js';
3
- import { __name } from '../chunk-SHUYVCID.js';
4
- import 'reflect-metadata';
5
- import { inject } from '@adonisjs/core';
6
- import { BaseCommand } from '@adonisjs/core/ace';
1
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.114.0/helpers/decorateMetadata.js";
2
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.114.0/helpers/decorate.js";
3
+ import { Scheduler } from "../src/scheduler.js";
4
+ import { BaseCommand } from "@adonisjs/core/ace";
5
+ import { inject } from "@adonisjs/core";
7
6
 
8
- function _ts_decorate(decorators, target, key, desc) {
9
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
11
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12
- return c > 3 && r && Object.defineProperty(target, key, r), r;
13
- }
14
- __name(_ts_decorate, "_ts_decorate");
15
- function _ts_metadata(k, v) {
16
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
17
- }
18
- __name(_ts_metadata, "_ts_metadata");
7
+ //#region commands/scheduler_run.ts
8
+ var _ref;
19
9
  var SchedulerRun = class extends BaseCommand {
20
- static {
21
- __name(this, "SchedulerRun");
22
- }
23
- static commandName = "scheduler:run";
24
- static description = "Run a scheduler";
25
- static options = {
26
- startApp: true,
27
- staysAlive: true
28
- };
29
- scheduler;
30
- prepare() {
31
- this.app.terminating(() => this.scheduler?.stop());
32
- }
33
- async run(scheduler) {
34
- this.scheduler = scheduler;
35
- await this.scheduler.start(true);
36
- }
10
+ static commandName = "scheduler:run";
11
+ static description = "Run a scheduler";
12
+ static options = {
13
+ startApp: true,
14
+ staysAlive: true
15
+ };
16
+ scheduler;
17
+ prepare() {
18
+ this.app.terminating(() => this.scheduler?.stop());
19
+ }
20
+ async run(scheduler) {
21
+ this.scheduler = scheduler;
22
+ await this.scheduler.start(true);
23
+ }
37
24
  };
38
- _ts_decorate([
39
- inject(),
40
- _ts_metadata("design:type", Function),
41
- _ts_metadata("design:paramtypes", [
42
- typeof Scheduler === "undefined" ? Object : Scheduler
43
- ]),
44
- _ts_metadata("design:returntype", Promise)
25
+ __decorate([
26
+ inject(),
27
+ __decorateMetadata("design:type", Function),
28
+ __decorateMetadata("design:paramtypes", [typeof (_ref = typeof Scheduler !== "undefined" && Scheduler) === "function" ? _ref : Object]),
29
+ __decorateMetadata("design:returntype", Promise)
45
30
  ], SchedulerRun.prototype, "run", null);
46
31
 
47
- export { SchedulerRun as default };
32
+ //#endregion
33
+ export { SchedulerRun as default };
@@ -1,26 +1,23 @@
1
- import { ApplicationService } from '@adonisjs/core/types';
2
- import { a as Scheduler, c as SchedulerEvents } from '../scheduler-vBDqaysB.js';
3
- import '@adonisjs/core/container';
4
- import '@adonisjs/lock/types';
5
- import '@adonisjs/core/logger';
6
- import '@adonisjs/core/events';
1
+ import { SchedulerEvents } from "../src/types.js";
2
+ import { Scheduler } from "../src/scheduler.js";
3
+ import { ApplicationService } from "@adonisjs/core/types";
7
4
 
5
+ //#region providers/scheduler.provider.d.ts
8
6
  declare class SchedulerProvider {
9
- protected app: ApplicationService;
10
- private scheduler?;
11
- constructor(app: ApplicationService);
12
- private getConfig;
13
- private getLocks;
14
- register(): void;
15
- ready(): Promise<void>;
16
- shutdown(): Promise<void>;
7
+ protected app: ApplicationService;
8
+ private scheduler?;
9
+ constructor(app: ApplicationService);
10
+ private getConfig;
11
+ private getLocks;
12
+ register(): void;
13
+ ready(): Promise<void>;
14
+ shutdown(): Promise<void>;
17
15
  }
18
16
  declare module '@adonisjs/core/types' {
19
- interface ContainerBindings {
20
- scheduler: Scheduler;
21
- }
22
- interface EventsList extends SchedulerEvents {
23
- }
17
+ interface ContainerBindings {
18
+ scheduler: Scheduler;
19
+ }
20
+ interface EventsList extends SchedulerEvents {}
24
21
  }
25
-
26
- export { SchedulerProvider as default };
22
+ //#endregion
23
+ export { SchedulerProvider as default };
@@ -1,41 +1,34 @@
1
- import { Scheduler } from '../chunk-6VW5PUDE.js';
2
- import '../chunk-OIXFFNQU.js';
3
- import { __name } from '../chunk-SHUYVCID.js';
1
+ import { Scheduler } from "../src/scheduler.js";
4
2
 
5
- // providers/scheduler.provider.ts
3
+ //#region providers/scheduler.provider.ts
6
4
  var SchedulerProvider = class {
7
- static {
8
- __name(this, "SchedulerProvider");
9
- }
10
- app;
11
- scheduler;
12
- constructor(app) {
13
- this.app = app;
14
- }
15
- getConfig() {
16
- return this.app.config.get("scheduler", {});
17
- }
18
- async getLocks() {
19
- if (this.app.container.hasBinding("lock.manager")) {
20
- return await this.app.container.make("lock.manager");
21
- }
22
- }
23
- register() {
24
- this.app.container.singleton(Scheduler, async () => {
25
- return new Scheduler(this.getConfig(), this.app.container.createResolver(), await this.app.container.make("logger"), await this.app.container.make("emitter"), await this.getLocks());
26
- });
27
- this.app.container.alias("scheduler", Scheduler);
28
- }
29
- async ready() {
30
- const config = this.getConfig();
31
- if (this.app.getEnvironment() === "web" && config.httpServer) {
32
- this.scheduler = await this.app.container.make(Scheduler);
33
- await this.scheduler.start();
34
- }
35
- }
36
- async shutdown() {
37
- await this.scheduler?.stop();
38
- }
5
+ scheduler;
6
+ constructor(app) {
7
+ this.app = app;
8
+ }
9
+ getConfig() {
10
+ return this.app.config.get("scheduler", {});
11
+ }
12
+ async getLocks() {
13
+ if (this.app.container.hasBinding("lock.manager")) return await this.app.container.make("lock.manager");
14
+ }
15
+ register() {
16
+ this.app.container.singleton(Scheduler, async () => {
17
+ return new Scheduler(this.getConfig(), this.app.container.createResolver(), await this.app.container.make("logger"), await this.app.container.make("emitter"), await this.getLocks());
18
+ });
19
+ this.app.container.alias("scheduler", Scheduler);
20
+ }
21
+ async ready() {
22
+ const config = this.getConfig();
23
+ if (this.app.getEnvironment() === "web" && config.httpServer) {
24
+ this.scheduler = await this.app.container.make(Scheduler);
25
+ await this.scheduler.start();
26
+ }
27
+ }
28
+ async shutdown() {
29
+ await this.scheduler?.stop();
30
+ }
39
31
  };
40
32
 
41
- export { SchedulerProvider as default };
33
+ //#endregion
34
+ export { SchedulerProvider as default };
@@ -1,10 +1,6 @@
1
- import { a as Scheduler } from '../scheduler-vBDqaysB.js';
2
- import '@adonisjs/core/container';
3
- import '@adonisjs/core/types';
4
- import '@adonisjs/lock/types';
5
- import '@adonisjs/core/logger';
6
- import '@adonisjs/core/events';
1
+ import { Scheduler } from "../src/scheduler.js";
7
2
 
3
+ //#region services/main.d.ts
8
4
  declare let scheduler: Scheduler;
9
-
10
- export { scheduler as default };
5
+ //#endregion
6
+ export { scheduler as default };
@@ -1,9 +1,10 @@
1
- import '../chunk-SHUYVCID.js';
2
- import app from '@adonisjs/core/services/app';
1
+ import app from "@adonisjs/core/services/app";
3
2
 
4
- var scheduler;
3
+ //#region services/main.ts
4
+ let scheduler;
5
5
  await app?.booted(async () => {
6
- scheduler = await app.container.make("scheduler");
6
+ scheduler = await app.container.make("scheduler");
7
7
  });
8
8
 
9
- export { scheduler as default };
9
+ //#endregion
10
+ export { scheduler as default };
@@ -0,0 +1,18 @@
1
+ import { Task } from "./task.js";
2
+ import ace from "@adonisjs/core/services/ace";
3
+
4
+ //#region src/command.task.ts
5
+ var CommandTask = class extends Task {
6
+ static command = [];
7
+ get name() {
8
+ return this.constructor.command.join(",");
9
+ }
10
+ async run() {
11
+ const [name, ...args] = this.constructor.command;
12
+ if (!name) throw new Error("No command name provided.");
13
+ await ace.exec(name, args);
14
+ }
15
+ };
16
+
17
+ //#endregion
18
+ export { CommandTask };
@@ -0,0 +1,6 @@
1
+ import { SchedulerConfig } from "./types.js";
2
+
3
+ //#region src/config.d.ts
4
+ declare function defineConfig<T extends SchedulerConfig>(config: T): T;
5
+ //#endregion
6
+ export { defineConfig };
@@ -0,0 +1,7 @@
1
+ //#region src/config.ts
2
+ function defineConfig(config) {
3
+ return config;
4
+ }
5
+
6
+ //#endregion
7
+ export { defineConfig };
@@ -0,0 +1,6 @@
1
+ import Configure from "@adonisjs/core/commands/configure";
2
+
3
+ //#region src/configure.d.ts
4
+ declare function configure(command: Configure): Promise<void>;
5
+ //#endregion
6
+ export { configure };
@@ -0,0 +1,15 @@
1
+ import path from "node:path";
2
+
3
+ //#region src/configure.ts
4
+ async function configure(command) {
5
+ const codemods = await command.createCodemods();
6
+ await codemods.makeUsingStub(path.resolve(import.meta.dirname, "..", "stubs"), "config/scheduler.stub", {});
7
+ await codemods.defineEnvVariables({ SCHEDULER_HTTP_SERVER: false });
8
+ await codemods.defineEnvValidations({ variables: { SCHEDULER_HTTP_SERVER: `Env.schema.boolean.optional()` } });
9
+ await codemods.updateRcFile((rcFile) => {
10
+ rcFile.addProvider("@outloud/adonis-scheduler/provider").addCommand("@outloud/adonis-scheduler/commands");
11
+ });
12
+ }
13
+
14
+ //#endregion
15
+ export { configure };
@@ -0,0 +1,9 @@
1
+ import timers from "node:timers/promises";
2
+
3
+ //#region src/helpers.ts
4
+ async function waitUntil(callback, interval = 50) {
5
+ while (!callback()) await timers.setTimeout(interval);
6
+ }
7
+
8
+ //#endregion
9
+ export { waitUntil };
@@ -0,0 +1,6 @@
1
+ import { SchedulerConfig, TaskOptions } from "./types.js";
2
+ import { Task } from "./task.js";
3
+ import { Scheduler } from "./scheduler.js";
4
+ import { configure } from "./configure.js";
5
+ import { defineConfig } from "./config.js";
6
+ export { Scheduler, type SchedulerConfig, Task, type TaskOptions, configure, defineConfig };
@@ -0,0 +1,6 @@
1
+ import { Task } from "./task.js";
2
+ import { Scheduler } from "./scheduler.js";
3
+ import { configure } from "./configure.js";
4
+ import { defineConfig } from "./config.js";
5
+
6
+ export { Scheduler, Task, configure, defineConfig };