Skip to content

Commit

Permalink
fix: set connectionstring in options as default in runtime config (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien authored Jun 15, 2024
1 parent 08a9c36 commit 46a1835
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineNuxtModule, createResolver, addServerPlugin, addTypeTemplate, addPlugin } from '@nuxt/kit'
import { resolvePath } from "mlly"
import { defu } from 'defu'
import type { RuntimeConfig } from '@nuxt/schema'

export interface ModuleOptions {
/**
Expand Down Expand Up @@ -45,6 +47,19 @@ export default defineNuxtModule<ModuleOptions>({
references.push({ path: resolver.resolve('./runtime/types.d.ts') })
})

if (options.connectionString) {
nuxt.options.runtimeConfig = defu(nuxt.options.runtimeConfig, {
public: {
applicationinsights: {
connectionString: options.connectionString
}
},
applicationinsights: {
connectionString: options.connectionString
}
}) as RuntimeConfig
}

if (options.serverEnabled) {
nuxt.options.nitro.modules = nuxt.options.nitro.modules || []
nuxt.options.nitro.modules.push(await resolvePath('nitro-applicationinsights'))
Expand Down

0 comments on commit 46a1835

Please sign in to comment.