Skip to content

Commit c38f1cb

Browse files
committed
refactor: add preset to playground
1 parent 9559e71 commit c38f1cb

File tree

4 files changed

+90
-44
lines changed

4 files changed

+90
-44
lines changed

packages/nuxt/playground/nuxt.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ export default defineNuxtConfig({
77
layoutTransition: false,
88
},
99

10+
nitro: {
11+
preset: fileURLToPath(new URL('./preset', import.meta.url)),
12+
// preset: 'nitro-preset-firebase',
13+
runtimeConfig: {
14+
firebase: {
15+
functions: {
16+
httpsOptions: {
17+
region: 'europe-west1',
18+
},
19+
},
20+
},
21+
},
22+
},
23+
1024
alias: {
1125
// import the dev version directly
1226
'vuefire/server': fileURLToPath(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import '#internal/nitro/virtual/polyfill'
2+
import { onRequest } from 'firebase-functions/v2/https'
3+
// auto imported
4+
// import { toNodeListener } from 'h3'
5+
6+
const nitroApp = useNitroApp()
7+
const appConfig = useAppConfig()
8+
const config = useRuntimeConfig()
9+
10+
export const server = onRequest(
11+
appConfig._firebaseV2HttpRequestOptions || {},
12+
toNodeListener(nitroApp.h3App)
13+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { fileURLToPath } from 'node:url'
2+
import type { NitroPreset } from 'nitropack'
3+
import type { HttpsOptions } from 'firebase-functions/v2/https'
4+
import type { RuntimeOptions } from 'firebase-functions'
5+
6+
export default {
7+
extends: 'firebase',
8+
entry: fileURLToPath(new URL('./entry.ts', import.meta.url)),
9+
} satisfies NitroPreset
10+
11+
// FIXME: doesn't work
12+
// declare module 'nitropack/config' {
13+
// interface PresetOptions {
14+
// firebase?: {
15+
// onRequestOptions?: HttpsOptions
16+
// }
17+
// }
18+
// }
19+
20+
interface FirebaseUserAppConfig {
21+
firebase?: {
22+
functions?: {
23+
runtimeOptions?: RuntimeOptions
24+
httpsOptions?: HttpsOptions
25+
}
26+
}
27+
}
28+
29+
declare module '@nuxt/schema' {
30+
// interface AppConfig extends FirebaseUserAppConfig {}
31+
interface RuntimeConfig extends FirebaseUserAppConfig {}
32+
}

pnpm-lock.yaml

Lines changed: 31 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)