nuxt-processor 0.0.6 → 0.0.8

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
@@ -5,10 +5,9 @@
5
5
  [![License][license-src]][license-href]
6
6
  [![Known Vulnerabilities](https://snyk.io/test/github/aidanhibbard/nuxt-processor/badge.svg)](https://snyk.io/test/github/aidanhibbard/nuxt-processor)
7
7
 
8
- ## Real background job processing for Nuxt
9
-
10
- <img width="752" height="402" alt="image" src="https://github.com/user-attachments/assets/9190d8e1-8a46-4b49-be5a-20f0a49fc8fe" />
8
+ ## Scalable processing for Nuxt
11
9
 
10
+ <img width="512" height="250" alt="image" src="https://github.com/user-attachments/assets/d238fb33-8373-46ec-b132-85170ab67c80" />
12
11
 
13
12
  Note: This package is under very active development! Please consider creating issues if you run into anything!
14
13
 
@@ -65,7 +64,11 @@ Create `server/queues/hello.ts`:
65
64
  ```ts
66
65
  import { defineQueue } from '#processor'
67
66
 
68
- export default defineQueue({
67
+ type HelloName = 'hello'
68
+ type HelloData = { message: string, ts: number }
69
+ type HelloResult = { echoed: string, processedAt: number }
70
+
71
+ export default defineQueue<HelloData, HelloResult, HelloName>({
69
72
  name: 'hello',
70
73
  options: {},
71
74
  })
@@ -77,14 +80,15 @@ Create `server/workers/hello.ts`:
77
80
 
78
81
  ```ts
79
82
  import { defineWorker } from '#processor'
80
- import type { Job } from '#bullmq'
81
83
 
82
- export default defineWorker({
84
+ type HelloName = 'hello'
85
+ type HelloData = { message: string, ts: number }
86
+ type HelloResult = { echoed: string, processedAt: number }
87
+
88
+ export default defineWorker<HelloName, HelloData, HelloResult>({
83
89
  name: 'hello',
84
- async processor(job: Job) {
85
- // do work
86
- console.log('processed', job.name, job.data)
87
- return job.data
90
+ async processor(job) {
91
+ return { echoed: job.data.message, processedAt: job.data.ts }
88
92
  },
89
93
  options: {},
90
94
  })
package/dist/cli.cjs CHANGED
@@ -8,7 +8,7 @@ const pathe = require('pathe');
8
8
  const consola = require('consola');
9
9
  const citty = require('citty');
10
10
  const kit = require('@nuxt/kit');
11
- const _package = require('./shared/nuxt-processor.BYUls4Ut.cjs');
11
+ const _package = require('./shared/nuxt-processor.CSspK4r-.cjs');
12
12
 
13
13
  const ensureNuxtProject = async (args) => {
14
14
  const dir = pathe.resolve(args.dir);
package/dist/cli.mjs CHANGED
@@ -6,7 +6,7 @@ import { resolve } from 'pathe';
6
6
  import { consola } from 'consola';
7
7
  import { createMain, defineCommand } from 'citty';
8
8
  import { loadNuxtConfig } from '@nuxt/kit';
9
- import { v as version, d as description, n as name } from './shared/nuxt-processor.BhHJSy2L.mjs';
9
+ import { v as version, d as description, n as name } from './shared/nuxt-processor.Blgdjku5.mjs';
10
10
 
11
11
  const ensureNuxtProject = async (args) => {
12
12
  const dir = resolve(args.dir);
package/dist/module.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const kit = require('@nuxt/kit');
4
- const _package = require('./shared/nuxt-processor.BYUls4Ut.cjs');
4
+ const _package = require('./shared/nuxt-processor.CSspK4r-.cjs');
5
5
  const node_path = require('node:path');
6
6
  const fg = require('fast-glob');
7
7
 
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-processor",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "compatibility": {
5
5
  "nuxt": "^4.0.0 || ^3.0.0"
6
6
  },
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useNuxt, createResolver, defineNuxtModule, addTypeTemplate } from '@nuxt/kit';
2
- import { c as configKey, a as compatibility, v as version, n as name } from './shared/nuxt-processor.BhHJSy2L.mjs';
2
+ import { c as configKey, a as compatibility, v as version, n as name } from './shared/nuxt-processor.Blgdjku5.mjs';
3
3
  import { relative } from 'node:path';
4
4
  import fg from 'fast-glob';
5
5
 
@@ -1,9 +1,9 @@
1
1
  import type { Queue, QueueOptions, JobsOptions } from '../utils/workers.js';
2
- type DefineQueueArgs = {
3
- name: Queue['name'];
2
+ type DefineQueueArgs<DefaultNameType extends string = string> = {
3
+ name: DefaultNameType;
4
4
  options?: Omit<QueueOptions, 'connection'> & {
5
5
  defaultJobOptions?: JobsOptions;
6
6
  };
7
7
  };
8
- export declare function defineQueue({ name, options }: DefineQueueArgs): Queue;
8
+ export declare function defineQueue<DataTypeOrJob = any, DefaultResultType = any, DefaultNameType extends string = string>({ name, options }: DefineQueueArgs<DefaultNameType>): Queue<DataTypeOrJob, DefaultResultType, DefaultNameType>;
9
9
  export default defineQueue;
@@ -1,8 +1,8 @@
1
1
  import type { Worker, WorkerOptions, Processor } from 'bullmq';
2
- type DefineWorkerArgs = {
3
- name: Worker['name'];
4
- processor: Processor;
2
+ type DefineWorkerArgs<NameType extends string = string, DataType = any, ResultType = any> = {
3
+ name: NameType;
4
+ processor: Processor<DataType, ResultType, NameType>;
5
5
  options?: Omit<WorkerOptions, 'connection'>;
6
6
  };
7
- export declare function defineWorker(args: DefineWorkerArgs): Worker;
7
+ export declare function defineWorker<NameType extends string = string, DataType = any, ResultType = any>(args: DefineWorkerArgs<NameType, DataType, ResultType>): Worker<DataType, ResultType, NameType>;
8
8
  export default defineWorker;
@@ -13,12 +13,12 @@ export declare function $workers(): {
13
13
  } & {
14
14
  url?: string;
15
15
  })) => void;
16
- createQueue: (name: string, options?: Omit<QueueOptions, "connection"> & {
16
+ createQueue: <DataTypeOrJob = any, DefaultResultType = any, DefaultNameType extends string = string>(name: DefaultNameType, options?: Omit<QueueOptions, "connection"> & {
17
17
  defaultJobOptions?: JobsOptions;
18
- }) => Queue<any, any, string, any, any, string>;
19
- createWorker: (name: string, processor: Processor, options?: Omit<WorkerOptions, "connection">) => Worker<any, any, string>;
18
+ }) => Queue<DataTypeOrJob, DefaultResultType, DefaultNameType>;
19
+ createWorker: <DataType = any, ResultType = any, NameType extends string = string>(name: NameType, processor: Processor<DataType, ResultType, NameType>, options?: Omit<WorkerOptions, "connection">) => Worker<DataType, ResultType, NameType>;
20
20
  stopAll: () => Promise<void>;
21
- readonly queues: Queue<any, any, string, any, any, string>[];
22
- readonly workers: Worker<any, any, string>[];
21
+ readonly queues: Queue<any, any, any, any, any, any>[];
22
+ readonly workers: Worker<any, any, any>[];
23
23
  };
24
24
  export type { Queue, Worker, Processor, QueueOptions, WorkerOptions, JobsOptions, Job };
@@ -9,11 +9,13 @@ export function $workers() {
9
9
  function setConnection(connection) {
10
10
  if (connection && typeof connection === "object" && "url" in connection && connection.url) {
11
11
  const { url, ...rest } = connection;
12
- registry.connection = new IORedis(url, rest);
12
+ const opts = { ...rest, maxRetriesPerRequest: null };
13
+ registry.connection = new IORedis(url, opts);
13
14
  } else if (typeof connection === "string") {
14
- registry.connection = new IORedis(connection);
15
+ registry.connection = new IORedis(connection, { maxRetriesPerRequest: null });
15
16
  } else {
16
- registry.connection = connection;
17
+ const normalized = { ...connection, maxRetriesPerRequest: null };
18
+ registry.connection = normalized;
17
19
  }
18
20
  }
19
21
  function createQueue(name, options) {
@@ -1,5 +1,5 @@
1
1
  const name = "nuxt-processor";
2
- const version = "0.0.6";
2
+ const version = "0.0.8";
3
3
  const description = "Nuxt Processor";
4
4
  const configKey = "processor";
5
5
  const compatibility = {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const name = "nuxt-processor";
4
- const version = "0.0.6";
4
+ const version = "0.0.8";
5
5
  const description = "Nuxt Processor";
6
6
  const configKey = "processor";
7
7
  const compatibility = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-processor",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Nuxt Processor",
5
5
  "repository": "https://github.com/aidanhibbard/nuxt-processor",
6
6
  "license": "MIT",