Skip to content

Commit

Permalink
fix: API endpoints validation (fixes #97)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Jan 21, 2025
1 parent c1d4fcb commit 9669b2f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ export default defineNuxtModule<ModuleOptions>({
const getRawComposableName = (endpointId: string) => `$${camelCase(endpointId)}`
const getDataComposableName = (endpointId: string) => `use${pascalCase(endpointId)}Data`

if (
!Object.keys(options.endpoints!).length
&& !nuxt.options.runtimeConfig.apiParty
) {
logger.error('Missing API endpoints configuration. Please check the `apiParty` module configuration in `nuxt.config.ts`.')
}

// Private runtime config
nuxt.options.runtimeConfig.apiParty = defu(
nuxt.options.runtimeConfig.apiParty,
Expand All @@ -137,6 +130,10 @@ export default defineNuxtModule<ModuleOptions>({

await nuxt.callHook('api-party:extend', resolvedOptions)

if (!Object.keys(resolvedOptions.endpoints).length) {
logger.warn('No API endpoints found. Please add at least one endpoint to your configuration.')
}

// Write options to public runtime config if client requests are enabled
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore: `client` types are not compatible
Expand Down

0 comments on commit 9669b2f

Please sign in to comment.