nuxt-processor 0.0.15 → 1.1.0

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
@@ -54,20 +54,20 @@ export default defineNuxtConfig({
54
54
  redis: {
55
55
  // Prefer a single URL if available (takes precedence over other fields)
56
56
  // e.g. redis://user:pass@host:6379/0
57
- url: process.env.NUXT_REDIS_URL,
58
- host: process.env.NUXT_REDIS_HOST ?? '127.0.0.1',
59
- port: Number(process.env.NUXT_REDIS_PORT ?? 6379),
60
- password: process.env.NUXT_REDIS_PASSWORD ?? '',
61
- username: process.env.NUXT_REDIS_USERNAME,
62
- db: Number(process.env.NUXT_REDIS_DB ?? 0),
57
+ url: process.env.REDIS_URL,
58
+ host: process.env.REDIS_HOST ?? '127.0.0.1',
59
+ port: Number(process.env.REDIS_PORT ?? 6379),
60
+ password: process.env.REDIS_PASSWORD ?? '',
61
+ username: process.env.REDIS_USERNAME,
62
+ db: Number(process.env.REDIS_DB ?? 0),
63
63
  // Optional connection behavior
64
64
  // Delay connecting until first Redis command (useful to avoid build-time connects)
65
- lazyConnect: process.env.NUXT_REDIS_LAZY_CONNECT
66
- ? process.env.NUXT_REDIS_LAZY_CONNECT === 'true'
65
+ lazyConnect: process.env.REDIS_LAZY_CONNECT
66
+ ? process.env.REDIS_LAZY_CONNECT === 'true'
67
67
  : undefined,
68
68
  // Milliseconds to wait before giving up when establishing the connection
69
- connectTimeout: process.env.NUXT_REDIS_CONNECT_TIMEOUT
70
- ? Number(process.env.NUXT_REDIS_CONNECT_TIMEOUT)
69
+ connectTimeout: process.env.REDIS_CONNECT_TIMEOUT
70
+ ? Number(process.env.REDIS_CONNECT_TIMEOUT)
71
71
  : undefined,
72
72
  },
73
73
  },
package/dist/cli.cjs CHANGED
@@ -5,7 +5,7 @@ const node_fs = require('node:fs');
5
5
  const pathe = require('pathe');
6
6
  const citty = require('citty');
7
7
  const kit = require('@nuxt/kit');
8
- const logger = require('./shared/nuxt-processor.anOQG_7p.cjs');
8
+ const logger = require('./shared/nuxt-processor.BrcyjXeL.cjs');
9
9
  const promises = require('node:readline/promises');
10
10
  const node_process = require('node:process');
11
11
  require('consola');
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import { resolve } from 'pathe';
4
4
  import { createMain, defineCommand } from 'citty';
5
5
  import { loadNuxtConfig } from '@nuxt/kit';
6
- import { l as logger, v as version, d as description, n as name } from './shared/nuxt-processor.Ff27cxgy.mjs';
6
+ import { l as logger, v as version, d as description, n as name } from './shared/nuxt-processor.CEsc8O4P.mjs';
7
7
  import { createInterface } from 'node:readline/promises';
8
8
  import { stdout, stdin } from 'node:process';
9
9
  import 'consola';
package/dist/module.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const kit = require('@nuxt/kit');
4
- const logger = require('./shared/nuxt-processor.anOQG_7p.cjs');
4
+ const logger = require('./shared/nuxt-processor.BrcyjXeL.cjs');
5
5
  const node_path = require('node:path');
6
6
  const fg = require('fast-glob');
7
7
  require('consola');
@@ -28,18 +28,20 @@ const scanFolder = async (path) => {
28
28
  return files;
29
29
  };
30
30
 
31
- function generateWorkersEntryContent(workerFiles, redisInline) {
31
+ function generateWorkersEntryContent(workerFiles) {
32
32
  const toImportArray = workerFiles.map((id) => `() => import(${JSON.stringify(id)})`).join(",\n ");
33
33
  return `
34
34
  import { fileURLToPath } from 'node:url'
35
35
  import { resolve as resolvePath } from 'node:path'
36
36
  import { consola } from 'consola'
37
+ import { useRuntimeConfig } from '#imports'
37
38
  import { $workers } from '#processor-utils'
38
39
 
39
40
  // Initialize connection as early as possible so any imports that register
40
41
  // workers/queues have a valid connection available.
41
42
  const api = $workers()
42
- api.setConnection(${redisInline})
43
+ const { redis } = useRuntimeConfig()
44
+ api.setConnection(process.env.REDIS_URL ? { ...redis, url: process.env.REDIS_URL } : redis)
43
45
 
44
46
  export async function createWorkersApp() {
45
47
  // Avoid EPIPE when stdout/stderr are closed by terminal (e.g., Ctrl+C piping)
@@ -146,28 +148,33 @@ const module$1 = kit.defineNuxtModule({
146
148
  // Default configuration options of the Nuxt module
147
149
  defaults: {
148
150
  redis: {
149
- host: process.env.NUXT_REDIS_HOST ?? "127.0.0.1",
150
- port: Number(process.env.NUXT_REDIS_PORT ?? 6379),
151
- password: process.env.NUXT_REDIS_PASSWORD ?? "",
152
- username: process.env.NUXT_REDIS_USERNAME ?? void 0,
151
+ host: process.env.REDIS_HOST ?? "127.0.0.1",
152
+ port: Number(process.env.REDIS_PORT ?? 6379),
153
+ password: process.env.REDIS_PASSWORD ?? "",
154
+ username: process.env.REDIS_USERNAME ?? void 0,
153
155
  // needs Redis >= 6
154
- db: Number(process.env.NUXT_REDIS_DB ?? 0),
156
+ db: Number(process.env.REDIS_DB ?? 0),
155
157
  // Defaults to 0 on ioredis
156
- lazyConnect: process.env.NUXT_REDIS_LAZY_CONNECT === "true" ? true : void 0,
157
- connectTimeout: process.env.NUXT_REDIS_CONNECT_TIMEOUT ? Number(process.env.NUXT_REDIS_CONNECT_TIMEOUT) : void 0,
158
- url: process.env.NUXT_REDIS_URL ?? void 0
158
+ lazyConnect: process.env.REDIS_LAZY_CONNECT === "true" ? true : void 0,
159
+ connectTimeout: process.env.REDIS_CONNECT_TIMEOUT ? Number(process.env.REDIS_CONNECT_TIMEOUT) : void 0,
160
+ url: process.env.REDIS_URL ?? void 0
159
161
  },
160
162
  workers: "server/workers"
161
163
  },
162
164
  async setup(_options, nuxt) {
163
165
  const { resolve } = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('module.cjs', document.baseURI).href)));
164
- const redisInline = JSON.stringify(_options.redis ?? {});
166
+ const runtimeConfig = nuxt.options.runtimeConfig;
167
+ runtimeConfig.redis = {
168
+ ..._options.redis ?? {},
169
+ ...runtimeConfig.redis ?? {}
170
+ };
165
171
  const nitroPlugin = `
166
- import { defineNitroPlugin } from '#imports'
172
+ import { defineNitroPlugin, useRuntimeConfig } from '#imports'
167
173
  import { $workers } from '#processor-utils'
168
174
 
169
175
  export default defineNitroPlugin(() => {
170
- $workers().setConnection(${redisInline})
176
+ const { redis } = useRuntimeConfig()
177
+ $workers().setConnection(process.env.REDIS_URL ? { ...redis, url: process.env.REDIS_URL } : redis)
171
178
  })
172
179
  `;
173
180
  const tpl = kit.addTemplate({
@@ -217,7 +224,7 @@ declare module '#bullmq' {
217
224
  virtualCode = "";
218
225
  return;
219
226
  }
220
- virtualCode = generateWorkersEntryContent(workerFiles, redisInline);
227
+ virtualCode = generateWorkersEntryContent(workerFiles);
221
228
  for (const id of workerFiles) {
222
229
  this.addWatchFile(id);
223
230
  }
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-processor",
3
- "version": "0.0.15",
3
+ "version": "1.1.0",
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, addTemplate, addServerPlugin, addTypeTemplate } from '@nuxt/kit';
2
- import { l as logger, c as configKey, a as compatibility, v as version, n as name } from './shared/nuxt-processor.Ff27cxgy.mjs';
2
+ import { l as logger, c as configKey, a as compatibility, v as version, n as name } from './shared/nuxt-processor.CEsc8O4P.mjs';
3
3
  import { relative } from 'node:path';
4
4
  import fg from 'fast-glob';
5
5
  import 'consola';
@@ -21,18 +21,20 @@ const scanFolder = async (path) => {
21
21
  return files;
22
22
  };
23
23
 
24
- function generateWorkersEntryContent(workerFiles, redisInline) {
24
+ function generateWorkersEntryContent(workerFiles) {
25
25
  const toImportArray = workerFiles.map((id) => `() => import(${JSON.stringify(id)})`).join(",\n ");
26
26
  return `
27
27
  import { fileURLToPath } from 'node:url'
28
28
  import { resolve as resolvePath } from 'node:path'
29
29
  import { consola } from 'consola'
30
+ import { useRuntimeConfig } from '#imports'
30
31
  import { $workers } from '#processor-utils'
31
32
 
32
33
  // Initialize connection as early as possible so any imports that register
33
34
  // workers/queues have a valid connection available.
34
35
  const api = $workers()
35
- api.setConnection(${redisInline})
36
+ const { redis } = useRuntimeConfig()
37
+ api.setConnection(process.env.REDIS_URL ? { ...redis, url: process.env.REDIS_URL } : redis)
36
38
 
37
39
  export async function createWorkersApp() {
38
40
  // Avoid EPIPE when stdout/stderr are closed by terminal (e.g., Ctrl+C piping)
@@ -139,28 +141,33 @@ const module$1 = defineNuxtModule({
139
141
  // Default configuration options of the Nuxt module
140
142
  defaults: {
141
143
  redis: {
142
- host: process.env.NUXT_REDIS_HOST ?? "127.0.0.1",
143
- port: Number(process.env.NUXT_REDIS_PORT ?? 6379),
144
- password: process.env.NUXT_REDIS_PASSWORD ?? "",
145
- username: process.env.NUXT_REDIS_USERNAME ?? void 0,
144
+ host: process.env.REDIS_HOST ?? "127.0.0.1",
145
+ port: Number(process.env.REDIS_PORT ?? 6379),
146
+ password: process.env.REDIS_PASSWORD ?? "",
147
+ username: process.env.REDIS_USERNAME ?? void 0,
146
148
  // needs Redis >= 6
147
- db: Number(process.env.NUXT_REDIS_DB ?? 0),
149
+ db: Number(process.env.REDIS_DB ?? 0),
148
150
  // Defaults to 0 on ioredis
149
- lazyConnect: process.env.NUXT_REDIS_LAZY_CONNECT === "true" ? true : void 0,
150
- connectTimeout: process.env.NUXT_REDIS_CONNECT_TIMEOUT ? Number(process.env.NUXT_REDIS_CONNECT_TIMEOUT) : void 0,
151
- url: process.env.NUXT_REDIS_URL ?? void 0
151
+ lazyConnect: process.env.REDIS_LAZY_CONNECT === "true" ? true : void 0,
152
+ connectTimeout: process.env.REDIS_CONNECT_TIMEOUT ? Number(process.env.REDIS_CONNECT_TIMEOUT) : void 0,
153
+ url: process.env.REDIS_URL ?? void 0
152
154
  },
153
155
  workers: "server/workers"
154
156
  },
155
157
  async setup(_options, nuxt) {
156
158
  const { resolve } = createResolver(import.meta.url);
157
- const redisInline = JSON.stringify(_options.redis ?? {});
159
+ const runtimeConfig = nuxt.options.runtimeConfig;
160
+ runtimeConfig.redis = {
161
+ ..._options.redis ?? {},
162
+ ...runtimeConfig.redis ?? {}
163
+ };
158
164
  const nitroPlugin = `
159
- import { defineNitroPlugin } from '#imports'
165
+ import { defineNitroPlugin, useRuntimeConfig } from '#imports'
160
166
  import { $workers } from '#processor-utils'
161
167
 
162
168
  export default defineNitroPlugin(() => {
163
- $workers().setConnection(${redisInline})
169
+ const { redis } = useRuntimeConfig()
170
+ $workers().setConnection(process.env.REDIS_URL ? { ...redis, url: process.env.REDIS_URL } : redis)
164
171
  })
165
172
  `;
166
173
  const tpl = addTemplate({
@@ -210,7 +217,7 @@ declare module '#bullmq' {
210
217
  virtualCode = "";
211
218
  return;
212
219
  }
213
- virtualCode = generateWorkersEntryContent(workerFiles, redisInline);
220
+ virtualCode = generateWorkersEntryContent(workerFiles);
214
221
  for (const id of workerFiles) {
215
222
  this.addWatchFile(id);
216
223
  }
@@ -1,18 +1,7 @@
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: 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("node:tls").ConnectionOptions;
13
- } & {
14
- url?: string;
15
- })) => void;
4
+ setConnection: (connection: string | import("bullmq").ConnectionOptions) => void;
16
5
  createQueue: <DataTypeOrJob = any, DefaultResultType = any, DefaultNameType extends string = string>(name: DefaultNameType, options?: Omit<QueueOptions, "connection"> & {
17
6
  defaultJobOptions?: JobsOptions;
18
7
  }) => Queue<DataTypeOrJob, DefaultResultType, DefaultNameType>;
@@ -1,5 +1,4 @@
1
1
  import { Queue, Worker } from "bullmq";
2
- import IORedis from "ioredis";
3
2
  const registry = {
4
3
  connection: void 0,
5
4
  queues: [],
@@ -8,16 +7,20 @@ const registry = {
8
7
  export function $workers() {
9
8
  function setConnection(connection) {
10
9
  if (connection && typeof connection === "object" && "url" in connection && connection.url) {
11
- const { url, ...rest } = connection;
12
- const opts = { ...rest, maxRetriesPerRequest: null };
13
- registry.connection = new IORedis(url, opts);
10
+ registry.connection = connection;
14
11
  } else if (typeof connection === "string") {
15
- registry.connection = new IORedis(connection, { maxRetriesPerRequest: null });
12
+ registry.connection = { url: connection };
16
13
  } else {
17
- const normalized = { ...connection, maxRetriesPerRequest: null };
18
- registry.connection = normalized;
14
+ registry.connection = connection;
19
15
  }
20
16
  }
17
+ function getWorkerConnection() {
18
+ if (!registry.connection) return registry.connection;
19
+ return {
20
+ ...registry.connection,
21
+ maxRetriesPerRequest: null
22
+ };
23
+ }
21
24
  function createQueue(name, options) {
22
25
  const queue = new Queue(name, {
23
26
  connection: registry.connection,
@@ -28,7 +31,7 @@ export function $workers() {
28
31
  }
29
32
  function createWorker(name, processor, options) {
30
33
  const worker = new Worker(name, processor, {
31
- connection: registry.connection,
34
+ connection: getWorkerConnection(),
32
35
  ...options,
33
36
  autorun: false
34
37
  });
@@ -3,7 +3,7 @@
3
3
  const consola = require('consola');
4
4
 
5
5
  const name = "nuxt-processor";
6
- const version = "0.0.15";
6
+ const version = "1.1.0";
7
7
  const description = "Nuxt Processor";
8
8
  const configKey = "processor";
9
9
  const compatibility = {
@@ -1,7 +1,7 @@
1
1
  import { createConsola } from 'consola';
2
2
 
3
3
  const name = "nuxt-processor";
4
- const version = "0.0.15";
4
+ const version = "1.1.0";
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.15",
3
+ "version": "1.1.0",
4
4
  "description": "Nuxt Processor",
5
5
  "repository": "https://github.com/aidanhibbard/nuxt-processor",
6
6
  "license": "MIT",
@@ -35,10 +35,12 @@
35
35
  "dev": "npm run dev:prepare && nuxi dev playground",
36
36
  "dev:build": "nuxi build playground",
37
37
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
38
- "release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
38
+ "release": "npm run ci && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
39
39
  "lint": "eslint .",
40
40
  "lint:fix": "eslint . --fix",
41
+ "typecheck": "nuxi typecheck",
41
42
  "test": "vitest run",
43
+ "ci": "npm run lint && npm run typecheck && npm run test",
42
44
  "test:coverage": "vitest run --coverage",
43
45
  "test:watch": "vitest watch",
44
46
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
@@ -47,30 +49,30 @@
47
49
  "vp:preview": "vitepress preview docs"
48
50
  },
49
51
  "dependencies": {
50
- "@nuxt/kit": "^4.3.0",
51
- "bullmq": "^5.67.2",
52
- "citty": "^0.2.0",
52
+ "@nuxt/kit": "^4.4.5",
53
+ "bullmq": "^5.76.7",
54
+ "citty": "^0.2.2",
53
55
  "consola": "^3.4.2",
54
56
  "fast-glob": "^3.3.3",
55
- "ioredis": "^5.9.2",
56
57
  "pathe": "^2.0.3"
57
58
  },
58
59
  "devDependencies": {
59
- "@nuxt/devtools": "^2.6.3",
60
- "@nuxt/eslint": "^1.9.0",
61
- "@nuxt/eslint-config": "^1.9.0",
60
+ "@nuxt/devtools": "^4.0.0-alpha.4",
61
+ "@nuxt/eslint": "^1.15.2",
62
+ "@nuxt/eslint-config": "^1.15.2",
62
63
  "@nuxt/module-builder": "^1.0.2",
63
- "@nuxt/schema": "^4.0.3",
64
- "@nuxt/test-utils": "^3.19.2",
64
+ "@nuxt/schema": "^4.4.5",
65
+ "@nuxt/test-utils": "^4.0.3",
65
66
  "@types/node": "latest",
66
- "@vitest/coverage-v8": "^3.2.4",
67
+ "@vitest/coverage-v8": "^4.1.5",
67
68
  "changelogen": "^0.6.2",
68
- "eslint": "^9.34.0",
69
- "happy-dom": "^20.0.11",
70
- "nuxt": "^4.0.3",
69
+ "eslint": "^10.3.0",
70
+ "happy-dom": "^20.9.0",
71
+ "nuxt": "^4.4.5",
71
72
  "typescript": "~5.9.2",
73
+ "unbuild": "^3.6.1",
72
74
  "vitepress": "^2.0.0-alpha.12",
73
- "vitest": "^3.2.4",
74
- "vue-tsc": "^3.0.6"
75
+ "vitest": "^4.1.5",
76
+ "vue-tsc": "^3.2.8"
75
77
  }
76
78
  }