From 6edb17d83dc729659f7db43560a6e0219765ec50 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 2 Oct 2022 13:40:11 +0100 Subject: [PATCH 1/6] feat(schema): add `routes` as shortcut for `nitro.routes` --- packages/schema/package.json | 1 + packages/schema/src/config/nitro.ts | 20 +++++++++++++++++++- yarn.lock | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/schema/package.json b/packages/schema/package.json index ec8e035aa99..495fa89f7b6 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -18,6 +18,7 @@ "@types/semver": "^7", "@vitejs/plugin-vue": "^3.1.2", "@vueuse/head": "~1.0.0-rc.7", + "nitropack": "^0.5.4", "unbuild": "latest", "vite": "~3.1.7" }, diff --git a/packages/schema/src/config/nitro.ts b/packages/schema/src/config/nitro.ts index dde14944453..2b9cd2d678f 100644 --- a/packages/schema/src/config/nitro.ts +++ b/packages/schema/src/config/nitro.ts @@ -10,7 +10,25 @@ export default defineUntypedSchema({ * @version 2 * @version 3 */ - nitro: {}, + nitro: { + routes: { + $resolve: async (val, get) => ({ + ...await get('routes') || {}, + ...val || {} + }) + } + }, + + /** + * Route rules for nitro server routes + * + * @see https://nitro.unjs.io/config/ + * + * @type {typeof import('nitropack')['NitroConfig']['routes']} + * @version 2 + * @version 3 + */ + routes: {}, /** * Nitro server handlers. diff --git a/yarn.lock b/yarn.lock index 1483db288d1..a2c340c3c14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1840,6 +1840,7 @@ __metadata: create-require: ^1.1.1 defu: ^6.1.0 jiti: ^1.16.0 + nitropack: ^0.5.4 pathe: ^0.3.9 pkg-types: ^0.3.5 postcss-import-resolver: ^2.0.0 From 2f7d83304f0e1c9db7d5d78399e489cd44f04805 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 2 Oct 2022 13:45:04 +0100 Subject: [PATCH 2/6] docs: improve wording --- packages/schema/src/config/nitro.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/schema/src/config/nitro.ts b/packages/schema/src/config/nitro.ts index 2b9cd2d678f..00466e17e71 100644 --- a/packages/schema/src/config/nitro.ts +++ b/packages/schema/src/config/nitro.ts @@ -20,7 +20,7 @@ export default defineUntypedSchema({ }, /** - * Route rules for nitro server routes + * Rules applied by nitro to your routes when building and at runtime * * @see https://nitro.unjs.io/config/ * From 08d9ff7a613965af42e2710d9c55493555e2b189 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 12 Oct 2022 23:06:10 +0100 Subject: [PATCH 3/6] docs: update wording --- packages/schema/src/config/nitro.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/schema/src/config/nitro.ts b/packages/schema/src/config/nitro.ts index 00466e17e71..e5612f1f769 100644 --- a/packages/schema/src/config/nitro.ts +++ b/packages/schema/src/config/nitro.ts @@ -20,7 +20,7 @@ export default defineUntypedSchema({ }, /** - * Rules applied by nitro to your routes when building and at runtime + * Universal rules applied to your routes when building and at runtime * * @see https://nitro.unjs.io/config/ * From db8ffcaa73623cba58f4eabed2791b2ef174b8d3 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sat, 15 Oct 2022 22:47:00 +0100 Subject: [PATCH 4/6] chore: match nitro version --- packages/schema/package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/schema/package.json b/packages/schema/package.json index 7e5f7a12156..add7aebe441 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -18,7 +18,7 @@ "@types/semver": "^7", "@vitejs/plugin-vue": "^3.1.2", "@vueuse/head": "~1.0.0-rc.9", - "nitropack": "^0.5.4", + "nitropack": "npm:nitropack-edge@0.5.5-27764245.b884d0c", "unbuild": "latest", "vite": "~3.1.8" }, diff --git a/yarn.lock b/yarn.lock index 781e012ecd4..d3725ff255e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1748,7 +1748,7 @@ __metadata: create-require: ^1.1.1 defu: ^6.1.0 jiti: ^1.16.0 - nitropack: ^0.5.4 + nitropack: "npm:nitropack-edge@0.5.5-27764245.b884d0c" pathe: ^0.3.9 pkg-types: ^0.3.5 postcss-import-resolver: ^2.0.0 From e7638adfb3065edc4dd5f3f9b897c4bbdc64c7b0 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 17 Oct 2022 12:31:54 +0200 Subject: [PATCH 5/6] update jsdocs --- packages/schema/src/config/nitro.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/schema/src/config/nitro.ts b/packages/schema/src/config/nitro.ts index e5612f1f769..0f310d88aa1 100644 --- a/packages/schema/src/config/nitro.ts +++ b/packages/schema/src/config/nitro.ts @@ -20,12 +20,13 @@ export default defineUntypedSchema({ }, /** - * Universal rules applied to your routes when building and at runtime + * Global route options applied to matching server routes. * - * @see https://nitro.unjs.io/config/ + * @experimental This is an experimental feature and API may change in the future. + * + * @see https://nitro.unjs.io/config/#routes * * @type {typeof import('nitropack')['NitroConfig']['routes']} - * @version 2 * @version 3 */ routes: {}, From 95554caf77709dc6a47c31b79a7451e9734be9e7 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 17 Oct 2022 12:20:55 +0100 Subject: [PATCH 6/6] refactor: use `routeRules` --- packages/schema/src/config/nitro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/schema/src/config/nitro.ts b/packages/schema/src/config/nitro.ts index 0f310d88aa1..e6067d61cb0 100644 --- a/packages/schema/src/config/nitro.ts +++ b/packages/schema/src/config/nitro.ts @@ -13,7 +13,7 @@ export default defineUntypedSchema({ nitro: { routes: { $resolve: async (val, get) => ({ - ...await get('routes') || {}, + ...await get('routeRules') || {}, ...val || {} }) } @@ -29,7 +29,7 @@ export default defineUntypedSchema({ * @type {typeof import('nitropack')['NitroConfig']['routes']} * @version 3 */ - routes: {}, + routeRules: {}, /** * Nitro server handlers.