Skip to content

Commbocc/hc-county-data-contentstack

Repository files navigation

County Data Stack — Contentstack API Proxy DAL

A thin Data Access Layer (DAL) that proxies requests to the Contentstack Content Delivery API. It forwards query parameters to Contentstack and returns responses to callers with minimal reshaping.

Security note: Top-level index access to the content_types and assets endpoints is blocked (HTTP 403) to prevent bulk data mining.


API Reference

Endpoints

Method Path
GET /api/v1/content_types/:content_type_uid/entries
GET /api/v1/assets/:asset_uid

Example — fetch entries for the communications_staff content type:

GET /api/v1/content_types/communications_staff/entries

Sorting

Append asc or desc with the field name:

?asc=email

Filtering

Pass a query parameter containing a JSON-encoded Contentstack query object:

const encoded = encodeURIComponent(
  JSON.stringify({ filter: { $in: ["MRS"] } })
);
// ?query=${encoded}

Pagination

Standard Contentstack pagination parameters are forwarded as-is, e.g. limit and skip.

Response Structure

Responses follow the Contentstack shape with minimal reshaping — e.g. { entries: [...] }. See the Contentstack Content Delivery API docs for full details.


Cache

The API proxy enables server-side caching to improve performance. Responses are cached for 1 hour (maxAge: 3600). Two per-request query flags control cache behavior:

  • bypassCache: when present and truthy, the handler bypasses the cache and fetches fresh data.
  • invalidateCache: when present and truthy, the handler returns data and invalidates any stored cache for that route.

Examples:

  • GET /api/v1/<path> — normal cached response.
  • GET /api/v1/<path>?bypassCache=1 — bypass cache and return fresh data.
  • GET /api/v1/<path>?invalidateCache=1 — return data and invalidate cached entry.

Development

Install dependencies

npm install   # or pnpm install / yarn install / bun install

Start dev server

Runs at http://localhost:3000:

npm run dev   # or pnpm dev / yarn dev / bun run dev

Build for production

npm run build   # or pnpm build / yarn build / bun run build

Preview production build

npm run preview   # or pnpm preview / yarn preview / bun run preview

See the Nuxt deployment docs for more.

Releases

No releases published

Packages

 
 
 

Contributors