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", 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;