Packages
@tsproxy/api

@tsproxy/api

HonoJS proxy server for Typesense with caching, rate limiting, and an ingestion queue.

Features

  • Search proxy — InstantSearch-compatible multi-search endpoint
  • LRU cache — configurable TTL and max size, error-aware (never caches failures)
  • Rate limiting — per-IP, configurable per endpoint
  • Ingestion queue — BullMQ (Redis) with in-memory fallback
  • Computed fields — transform documents during ingestion
  • Config filetsproxy.config.ts with defineConfig helper
  • CLItsproxy dev and tsproxy start commands

Endpoints

MethodPathAuthDescription
POST/api/searchNoMulti-search (Algolia format)
GET/api/healthNoHealth check (Typesense + Redis)
GET/api/docsNoOpenAPI documentation
POST/api/ingest/:collection/documentsYesUpsert document
POST/api/ingest/:collection/documents/importYesBulk import
PATCH/api/ingest/:collection/documents/:idYesPartial update
DELETE/api/ingest/:collection/documents/:idYesDelete document
DELETE/api/ingest/:collection/documentsYesDelete by filter
GET/api/ingest/queue/statusYesQueue stats

Config File

import { defineConfig } from "@tsproxy/api";
 
export default defineConfig({
  typesense: {
    host: "localhost",
    port: 8108,
    apiKey: "your-key",
  },
  server: { port: 3000, apiKey: "ingest-secret" },
  cache: { ttl: 60, maxSize: 1000 },
  queue: {
    concurrency: 5,
    maxSize: 10000,
    redis: { host: "localhost", port: 6379 },
  },
  rateLimit: { search: 100, ingest: 30 },
  collections: {
    products: {
      fields: {
        name: { type: "string", searchable: true },
        price: { type: "float", sortable: true },
        category: { type: "string", facet: true },
      },
      locales: ["en", "fr"],
      defaultSortBy: "created_at",
    },
  },
});

Field Types

TypeDescription
searchableIncluded in query_by for search
facetAvailable for faceted filtering
sortableAvailable for sort ordering
optionalAllow null/missing values
computeTransform function (doc, locale?) => value

Exports

import {
  createApp,
  loadConfig,
  defineConfig,
  resolveCollection,
  getSearchableFields,
  getFacetFields,
  getSortableFields,
  LRUCache,
  IngestionQueue,
  transformAlgoliaRequestToTypesense,
  transformMultiSearchResponse,
} from "@tsproxy/api";