Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate schema functions, replace with nuxt hooks #87

Open
3 tasks done
mattmess1221 opened this issue Nov 6, 2024 · 0 comments
Open
3 tasks done

Deprecate schema functions, replace with nuxt hooks #87

mattmess1221 opened this issue Nov 6, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mattmess1221
Copy link
Contributor

Describe the feature

As of nuxt 3.14, using a function for the schema prints this to console.

WARN  Runtime config option apiParty.endpoints.foo.schema may not be able to be serialized.

I suggest using a hook that can update the endpoint. Hooks could also be added to intercept the API requests. Adding authorization, extra headers, request filtering, etc.

It would be used similarly to this.

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-api-party'],
  apiParty: {
    endpoints: {
      foo: {
        url: 'http://localhost:8000'
      }
    }
  },
  // new hooks used instead of function
  hooks: {
    'api-party:resolve': async (id, endpoint) => {
      // set the schema value
      endpoint.schema = {
        // TODO
      }
    },
  }
})

Additional possible hooks

// plugins/api-auth.ts
export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hooks.hook('api-party:fetch', async (request, {event}) => {
    // TODO
  })
})
// server/plugins/api-auth.ts
export default defineNitroPlugin((nitroApp) => {
  nitroApp.hooks.hook('api-party:request', async (request, {event}) => {
    // TODO
  })
})

Additional information

  • Would you be willing to help implement this feature?
  • Can you think of other implementations of this feature?

Final checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants