Skip to content

Commit

Permalink
chore(skeleton): load config and provide to front&back
Browse files Browse the repository at this point in the history
  • Loading branch information
hywax committed Dec 28, 2023
1 parent 644f690 commit c06aa53
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server/plugins/1.config-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default defineNitroPlugin(async (nitroApp) => {
const localConfig = getLocalConfig()

if (!localConfig) {
console.error('Config not loaded!')
return
}

// Provide full config to backend
const storage = useStorage()
await storage.setItem('services', extractServicesFromConfig(localConfig))

// Provide safely config to frontend
nitroApp.hooks.hook('site-config:init', ({ siteConfig }) => {
siteConfig.push(extractSafelyConfig(localConfig))
})
})

0 comments on commit c06aa53

Please sign in to comment.