johannschopplich/nuxt-api-party
Tentang
π¬ Auto-generated composables for any API, typed from OpenAPI, with your credentials kept on the server
Pengembangan web dan aplikasiYang dapat Anda lakukan
- πͺ Auto-generated composables for each API
- π API credentials kept on the server by a server proxy
- π No CORS issues
- π± Built on Nuxt's useFetch and $fetch
Pertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- 0
- dalam 15 hari
- +2
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliNuxt API Party
Auto-generated composables for any API in Nuxt, typed from OpenAPI, with your credentials kept on the server.
Features
- πͺ Auto-generated composables for each API
- π API credentials kept on the server by a server proxy
- π No CORS issues
- π± Built on Nuxt's
useFetchand$fetch - π§ Connect all your APIs
- π¦Ύ Fully typed API clients from OpenAPI documents, with nothing else to install
- π Cached responses and hydration
Setup
npx nuxt module add api-party
Basic Usage
Add Nuxt API Party to your Nuxt configuration and describe your first API under the apiParty module option:
// `nuxt.config.ts`
export default defineNuxtConfig({
modules: ['nuxt-api-party'],
apiParty: {
endpoints: {
jsonPlaceholder: {
url: process.env.JSON_PLACEHOLDER_API_BASE_URL!,
// Sent as a bearer token with each request, from the server
token: process.env.JSON_PLACEHOLDER_API_TOKEN,
},
},
},
})
For an endpoint jsonPlaceholder, the module generates:
$jsonPlaceholderβ Returns the response data, similar to$fetchuseJsonPlaceholderDataβ Returns multiple values similar touseFetch
Use these composables in your templates or components:
<script setup lang="ts">
const { data, refresh, error, status, clear } = await useJsonPlaceholderData<{ title: string }>(
'posts/1',
)
</script>
<template>
<h1>{{ data?.title }}</h1>
<pre>{{ JSON.stringify(data, undefined, 2) }}</pre>
</template>
Connect as many APIs as you need: each entry in endpoints gets its own pair of composables.
The documentation covers the OpenAPI integration, caching, credential forwarding and every module option. Coming from v4? See the migration guide.
π» Development
- Clone this repository
- Enable Corepack using
corepack enable - Install dependencies using
pnpm install - Run
pnpm run dev:prepare - Start development server using
pnpm run dev
Credits
- Dennis Baum for sponsoring the initial version of this package.
- Konkon for his logo pixel art.
License
MIT License Β© 2022-PRESENT Johann Schopplich and Β© 2025-PRESENT Matthew Messinger
Jelajahi proyek terkait
Memuatβ¦
