From 356198b4135c1242476bcc32778f583a48a197a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Filho?= Date: Wed, 29 Oct 2025 10:27:49 -0300 Subject: [PATCH 1/2] fix: routing rule for handling Nuxt content API requests and adds a polyfill for the Node.js console (#300) * fix: add console.time and console.timeEnd polyfills for node globals * fix: add rule to handle @nuxt/content API requests in function --- packages/presets/src/presets/nuxt/config.ts | 30 +++++++++++++++++++ packages/unenv-preset/src/index.ts | 1 + .../src/polyfills/node/globals/console.js | 20 +++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 packages/unenv-preset/src/polyfills/node/globals/console.js diff --git a/packages/presets/src/presets/nuxt/config.ts b/packages/presets/src/presets/nuxt/config.ts index d1921c02..619e163f 100644 --- a/packages/presets/src/presets/nuxt/config.ts +++ b/packages/presets/src/presets/nuxt/config.ts @@ -125,6 +125,36 @@ const config: AzionConfig = { }, ], }, + { + name: 'Execute Nuxt Function when starts with /api/_content', + description: + 'Handle @nuxt/content API requests - executes Nuxt function for content management endpoints. Remove this rule if your project does not use the @nuxt/content library.', + active: true, + criteria: [ + [ + { + variable: '${uri}', + conditional: 'if', + operator: 'starts_with', + argument: '/api/_content', + }, + ], + ], + behaviors: [ + { + type: 'run_function', + attributes: { + value: '$FUNCTION_NAME', + }, + }, + { + type: 'forward_cookies', + }, + { + type: 'deliver', + }, + ], + }, { name: 'Deliver Static Assets', description: 'Deliver static assets directly from storage', diff --git a/packages/unenv-preset/src/index.ts b/packages/unenv-preset/src/index.ts index 45db6209..f2ddcd53 100644 --- a/packages/unenv-preset/src/index.ts +++ b/packages/unenv-preset/src/index.ts @@ -15,6 +15,7 @@ export default { performance: `unenv/polyfill/performance`, setInterval: `${polyfillsPath}/node/globals/set-interval.js`, clearInterval: `${polyfillsPath}/node/globals/clear-interval.js`, + console: `${polyfillsPath}/node/globals/console.js`, }, alias: { 'azion/utils': 'azion/utils', diff --git a/packages/unenv-preset/src/polyfills/node/globals/console.js b/packages/unenv-preset/src/polyfills/node/globals/console.js new file mode 100644 index 00000000..30bf9525 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/globals/console.js @@ -0,0 +1,20 @@ +globalThis.__mockTimers = new Map(); + +const _console = globalThis.console; + +_console.time = (label = 'default') => { + globalThis.__mockTimers.set(label, Date.now()); +}; +_console.timeEnd = (label = 'default') => { + const startTime = globalThis.__mockTimers.get(label); + if (startTime) { + const duration = Date.now() - startTime; + globalThis.__mockTimers.delete(label); + return duration; + } + return 0; +}; + +globalThis.console = _console; + +export default globalThis.console; From d98457e4a804318037ca535efd60562e44c01e16 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 29 Oct 2025 13:29:02 +0000 Subject: [PATCH 2/2] chore(release): 2.2.2-stage.1 [skip ci] ### [2.2.2-stage.1](https://github.com/aziontech/lib/compare/v2.2.1...v2.2.2-stage.1) (2025-10-29) ### Bug Fixes * routing rule for handling Nuxt content API requests and adds a polyfill for the Node.js console (#300) ([356198b](https://github.com/aziontech/lib/commit/356198b4135c1242476bcc32778f583a48a197a0)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a3895e4..ba256702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### [2.2.2-stage.1](https://github.com/aziontech/lib/compare/v2.2.1...v2.2.2-stage.1) (2025-10-29) + + +### Bug Fixes + +* routing rule for handling Nuxt content API requests and adds a polyfill for the Node.js console (#300) ([356198b](https://github.com/aziontech/lib/commit/356198b4135c1242476bcc32778f583a48a197a0)) + ### [2.2.1](https://github.com/aziontech/lib/compare/v2.2.0...v2.2.1) (2025-10-22) diff --git a/package.json b/package.json index f2547945..6be37ff2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azion", - "version": "2.2.1", + "version": "2.2.2-stage.1", "description": "Azion Packages for Edge Computing.", "scripts": { "prepare": "husky",