@fubar-it-co/tmdb-client
v0.0.14
Published
TMDB API client generated with heyAPI
Downloads
1,167
Readme
@fubar-it-co/tmdb-client
TMDB API HTTP client generated with heyAPI from the official OpenAPI specification.
Features
- Type-safe: All endpoints and responses are fully typed
- TanStack Query integration: Generated query options for React Query
- Fetch API: Lightweight client based on native Fetch API
- Auto-generated: Regenerate anytime with
pnpm generate
Installation
This package is part of the monorepo. Dependencies are managed at the workspace level.
pnpm installUsage
SDK Functions
import { moviePopularList, movieDetails } from '@fubar-it-co/tmdb-client'
// Get popular movies
const { data } = await moviePopularList({ query: { page: 1 } })
// Get movie details
const { data: movie } = await movieDetails({ path: { movie_id: 550 } })With TanStack Query
import { useQuery } from '@tanstack/react-query'
import { moviePopularListOptions, movieDetailsOptions } from '@fubar-it-co/tmdb-client'
// In a React component
const { data, isLoading } = useQuery(moviePopularListOptions({ query: { page: 1 } }))
const { data: movie } = useQuery(movieDetailsOptions({ path: { movie_id: 550 } }))Configuration
The client is configured in src/tmdb-config.ts:
- Base URL:
https://api.themoviedb.org - Authentication: Bearer token from
VITE_TMDB_API_TOKENenvironment variable
Environment Variables
Create a .env.local file at the monorepo root:
VITE_TMDB_API_TOKEN=your_tmdb_bearer_token_hereRegenerating the Client
If the TMDB OpenAPI spec changes, regenerate the client:
pnpm --filter @fubar-it-co/tmdb-client generateFile Structure
packages/http-client/
├── src/
│ ├── client/ # Generated by heyAPI (do not edit)
│ │ ├── client.gen.ts # HTTP client instance
│ │ ├── sdk.gen.ts # SDK functions
│ │ ├── types.gen.ts # TypeScript types
│ │ └── tanstack-query.gen.ts # TanStack Query options
│ ├── tmdb-config.ts # Runtime configuration (auth, baseUrl)
│ └── index.ts # Package entry point
├── openapi-ts.config.ts # heyAPI configuration
├── package.json
└── tsconfig.jsonPublishing
Local testing with Verdaccio
Start Verdaccio (one-time global install):
npm install -g verdaccio
verdaccioFirst time only — register on local Verdaccio (saves token in .npmrc):
cd packages/http-client
npm adduser --registry http://localhost:4873/ --userconfig ../../.npmrcThen publish to Verdaccio:
./packages/http-client/publish-local.sh patchPublish to npm
./packages/http-client/publish.sh patchRequires NPM_TOKEN in .env at the monorepo root.
