From 90134844373dcff7a682f39db6d4fd2202aa0c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sat, 28 Oct 2023 08:33:25 +0200 Subject: [PATCH] chore: Add runtime config --- playground/.env.example | 3 +++ .../server/routes/{ => auth}/github.get.ts | 0 src/module.ts | 20 +++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 playground/.env.example rename playground/server/routes/{ => auth}/github.get.ts (100%) diff --git a/playground/.env.example b/playground/.env.example new file mode 100644 index 00000000..95d92b6f --- /dev/null +++ b/playground/.env.example @@ -0,0 +1,3 @@ +NUXT_SESSION_PASSWORD= +NUXT_OAUTH_GITHUB_CLIENT_ID= +NUXT_OAUTH_GITHUB_CLIENT_SECRET= diff --git a/playground/server/routes/github.get.ts b/playground/server/routes/auth/github.get.ts similarity index 100% rename from playground/server/routes/github.get.ts rename to playground/server/routes/auth/github.get.ts diff --git a/src/module.ts b/src/module.ts index 672fe4fc..7d187df7 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1,5 +1,6 @@ import { defineNuxtModule, addPlugin, createResolver, addImportsDir, addServerImportsDir, addServerHandler } from '@nuxt/kit' import { sha256 } from 'ohash' +import { defu } from 'defu' // Module options TypeScript interface definition export interface ModuleOptions {} @@ -40,5 +41,24 @@ export default defineNuxtModule({ route: '/api/_auth/session', method: 'get' }) + + // Runtime Config + const runtimeConfig = nuxt.options.runtimeConfig + runtimeConfig.session = defu(runtimeConfig.session, { + name: 'nuxt-session', + password: '' + }) + // OAuth settings + runtimeConfig.oauth = defu(runtimeConfig.oauth, {}) + // GitHub Oauth + runtimeConfig.oauth.github = defu(runtimeConfig.oauth.github, { + clientId: '', + clientSecret: '' + }) + // Spotify Oauth + runtimeConfig.oauth.spotify = defu(runtimeConfig.oauth.spotify, { + clientId: '', + clientSecret: '' + }) } })