nuxt-processor 0.0.5 → 0.0.6
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 +15 -8
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/module.cjs +7 -2
- package/dist/module.d.cts +4 -1
- package/dist/module.d.mts +4 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +7 -2
- package/dist/runtime/server/utils/workers.d.ts +12 -1
- package/dist/runtime/server/utils/workers.js +9 -1
- package/dist/shared/{nuxt-processor.BkxOOpC5.cjs → nuxt-processor.BYUls4Ut.cjs} +1 -1
- package/dist/shared/{nuxt-processor.CIK-4owC.mjs → nuxt-processor.BhHJSy2L.mjs} +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
[![License][license-src]][license-href]
|
|
6
6
|
[](https://snyk.io/test/github/aidanhibbard/nuxt-processor)
|
|
7
7
|
|
|
8
|
-
|
|
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" />
|
|
9
11
|
|
|
10
|
-
<img width="763" height="321" alt="image" src="https://github.com/user-attachments/assets/f49d79a9-f99a-4612-b3bc-cad724475bf4" />
|
|
11
12
|
|
|
12
13
|
Note: This package is under very active development! Please consider creating issues if you run into anything!
|
|
13
14
|
|
|
@@ -18,7 +19,7 @@ Note: This package is under very active development! Please consider creating is
|
|
|
18
19
|
|
|
19
20
|
- **Dedicated processing**: Workers run in a separate Node process – no coupling to your web server.
|
|
20
21
|
- **Scalability**: Run multiple worker processes and instances across machines.
|
|
21
|
-
- **Simple DX**: Define queues/workers
|
|
22
|
+
- **Simple DX**: Define queues/workers using first-class helpers.
|
|
22
23
|
|
|
23
24
|
## Sections
|
|
24
25
|
|
|
@@ -44,9 +45,14 @@ export default defineNuxtConfig({
|
|
|
44
45
|
modules: ['nuxt-processor'],
|
|
45
46
|
processor: {
|
|
46
47
|
redis: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// Prefer a single URL if available (takes precedence over other fields)
|
|
49
|
+
// e.g. redis://user:pass@host:6379/0
|
|
50
|
+
url: process.env.NUXT_REDIS_URL,
|
|
51
|
+
host: process.env.NUXT_REDIS_HOST ?? '127.0.0.1',
|
|
52
|
+
port: Number(process.env.NUXT_REDIS_PORT ?? 6379),
|
|
53
|
+
password: process.env.NUXT_REDIS_PASSWORD ?? '',
|
|
54
|
+
username: process.env.NUXT_REDIS_USERNAME,
|
|
55
|
+
db: Number(process.env.NUXT_REDIS_DB ?? 0),
|
|
50
56
|
},
|
|
51
57
|
},
|
|
52
58
|
})
|
|
@@ -54,19 +60,20 @@ export default defineNuxtConfig({
|
|
|
54
60
|
|
|
55
61
|
## Define a queue and enqueue from your app
|
|
56
62
|
|
|
57
|
-
Create `server/queues/
|
|
63
|
+
Create `server/queues/hello.ts`:
|
|
58
64
|
|
|
59
65
|
```ts
|
|
60
66
|
import { defineQueue } from '#processor'
|
|
61
67
|
|
|
62
68
|
export default defineQueue({
|
|
63
69
|
name: 'hello',
|
|
70
|
+
options: {},
|
|
64
71
|
})
|
|
65
72
|
```
|
|
66
73
|
|
|
67
74
|
## Define a worker
|
|
68
75
|
|
|
69
|
-
Create `server/workers/
|
|
76
|
+
Create `server/workers/hello.ts`:
|
|
70
77
|
|
|
71
78
|
```ts
|
|
72
79
|
import { defineWorker } from '#processor'
|
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.
|
|
11
|
+
const _package = require('./shared/nuxt-processor.BYUls4Ut.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.
|
|
9
|
+
import { v as version, d as description, n as name } from './shared/nuxt-processor.BhHJSy2L.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.
|
|
4
|
+
const _package = require('./shared/nuxt-processor.BYUls4Ut.cjs');
|
|
5
5
|
const node_path = require('node:path');
|
|
6
6
|
const fg = require('fast-glob');
|
|
7
7
|
|
|
@@ -36,7 +36,12 @@ const module$1 = kit.defineNuxtModule({
|
|
|
36
36
|
redis: {
|
|
37
37
|
host: process.env.NUXT_REDIS_HOST ?? "127.0.0.1",
|
|
38
38
|
port: Number(process.env.NUXT_REDIS_PORT ?? 6379),
|
|
39
|
-
password: process.env.NUXT_REDIS_PASSWORD ?? ""
|
|
39
|
+
password: process.env.NUXT_REDIS_PASSWORD ?? "",
|
|
40
|
+
username: process.env.NUXT_REDIS_USERNAME ?? void 0,
|
|
41
|
+
// needs Redis >= 6
|
|
42
|
+
db: Number(process.env.NUXT_REDIS_DB ?? 0),
|
|
43
|
+
// Defaults to 0 on ioredis
|
|
44
|
+
url: process.env.NUXT_REDIS_URL ?? void 0
|
|
40
45
|
},
|
|
41
46
|
workers: "server/workers"
|
|
42
47
|
},
|
package/dist/module.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { RedisOptions } from 'bullmq';
|
|
3
3
|
|
|
4
|
+
type ModuleRedisOptions = RedisOptions & {
|
|
5
|
+
url?: string;
|
|
6
|
+
};
|
|
4
7
|
interface ModuleOptions {
|
|
5
|
-
redis:
|
|
8
|
+
redis: ModuleRedisOptions;
|
|
6
9
|
/**
|
|
7
10
|
* The folder containing the worker files
|
|
8
11
|
* Scans for {ts,js,mjs}
|
package/dist/module.d.mts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { RedisOptions } from 'bullmq';
|
|
3
3
|
|
|
4
|
+
type ModuleRedisOptions = RedisOptions & {
|
|
5
|
+
url?: string;
|
|
6
|
+
};
|
|
4
7
|
interface ModuleOptions {
|
|
5
|
-
redis:
|
|
8
|
+
redis: ModuleRedisOptions;
|
|
6
9
|
/**
|
|
7
10
|
* The folder containing the worker files
|
|
8
11
|
* Scans for {ts,js,mjs}
|
package/dist/module.json
CHANGED
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.
|
|
2
|
+
import { c as configKey, a as compatibility, v as version, n as name } from './shared/nuxt-processor.BhHJSy2L.mjs';
|
|
3
3
|
import { relative } from 'node:path';
|
|
4
4
|
import fg from 'fast-glob';
|
|
5
5
|
|
|
@@ -29,7 +29,12 @@ const module = defineNuxtModule({
|
|
|
29
29
|
redis: {
|
|
30
30
|
host: process.env.NUXT_REDIS_HOST ?? "127.0.0.1",
|
|
31
31
|
port: Number(process.env.NUXT_REDIS_PORT ?? 6379),
|
|
32
|
-
password: process.env.NUXT_REDIS_PASSWORD ?? ""
|
|
32
|
+
password: process.env.NUXT_REDIS_PASSWORD ?? "",
|
|
33
|
+
username: process.env.NUXT_REDIS_USERNAME ?? void 0,
|
|
34
|
+
// needs Redis >= 6
|
|
35
|
+
db: Number(process.env.NUXT_REDIS_DB ?? 0),
|
|
36
|
+
// Defaults to 0 on ioredis
|
|
37
|
+
url: process.env.NUXT_REDIS_URL ?? void 0
|
|
33
38
|
},
|
|
34
39
|
workers: "server/workers"
|
|
35
40
|
},
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { Job, JobsOptions, QueueOptions, WorkerOptions, Processor } from 'bullmq';
|
|
2
2
|
import { Queue, Worker } from 'bullmq';
|
|
3
3
|
export declare function $workers(): {
|
|
4
|
-
setConnection: (connection:
|
|
4
|
+
setConnection: (connection: string | import("bullmq").ConnectionOptions | (import("ioredis").CommonRedisOptions & import("ioredis").SentinelConnectionOptions & Partial<{
|
|
5
|
+
port: number;
|
|
6
|
+
host?: string | undefined | undefined;
|
|
7
|
+
family?: number | undefined | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
path: string;
|
|
10
|
+
}> & {
|
|
11
|
+
disconnectTimeout?: number;
|
|
12
|
+
tls?: import("tls").ConnectionOptions;
|
|
13
|
+
} & {
|
|
14
|
+
url?: string;
|
|
15
|
+
})) => void;
|
|
5
16
|
createQueue: (name: string, options?: Omit<QueueOptions, "connection"> & {
|
|
6
17
|
defaultJobOptions?: JobsOptions;
|
|
7
18
|
}) => Queue<any, any, string, any, any, string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Queue, Worker } from "bullmq";
|
|
2
|
+
import IORedis from "ioredis";
|
|
2
3
|
const registry = {
|
|
3
4
|
connection: void 0,
|
|
4
5
|
queues: [],
|
|
@@ -6,7 +7,14 @@ const registry = {
|
|
|
6
7
|
};
|
|
7
8
|
export function $workers() {
|
|
8
9
|
function setConnection(connection) {
|
|
9
|
-
|
|
10
|
+
if (connection && typeof connection === "object" && "url" in connection && connection.url) {
|
|
11
|
+
const { url, ...rest } = connection;
|
|
12
|
+
registry.connection = new IORedis(url, rest);
|
|
13
|
+
} else if (typeof connection === "string") {
|
|
14
|
+
registry.connection = new IORedis(connection);
|
|
15
|
+
} else {
|
|
16
|
+
registry.connection = connection;
|
|
17
|
+
}
|
|
10
18
|
}
|
|
11
19
|
function createQueue(name, options) {
|
|
12
20
|
const queue = new Queue(name, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-processor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Nuxt Processor",
|
|
5
5
|
"repository": "https://github.com/aidanhibbard/nuxt-processor",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
39
39
|
"lint": "eslint .",
|
|
40
40
|
"test": "vitest run",
|
|
41
|
+
"test:coverage": "vitest run --coverage",
|
|
41
42
|
"test:watch": "vitest watch",
|
|
42
43
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
43
44
|
"vp:dev": "vitepress dev docs",
|
|
@@ -46,9 +47,9 @@
|
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
49
|
"@nuxt/kit": "^4.0.3",
|
|
50
|
+
"bullmq": "^5.58.2",
|
|
49
51
|
"citty": "^0.1.6",
|
|
50
52
|
"consola": "^3.2.3",
|
|
51
|
-
"bullmq": "^5.58.2",
|
|
52
53
|
"fast-glob": "^3.3.3",
|
|
53
54
|
"ioredis": "^5.7.0",
|
|
54
55
|
"pathe": "^1.1.2"
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@nuxt/schema": "^4.0.3",
|
|
62
63
|
"@nuxt/test-utils": "^3.19.2",
|
|
63
64
|
"@types/node": "latest",
|
|
65
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
64
66
|
"changelogen": "^0.6.2",
|
|
65
67
|
"eslint": "^9.34.0",
|
|
66
68
|
"happy-dom": "^18.0.1",
|