Advanced concepts

Combining APIs

Sometimes, you don't want to have multiple domains for your services. While you can create reverse proxies/load balancers to handle routing for you, the @workertown/utils package provides a simple way to combine multiple services into a single REST API.


Install the @workertown/utils package and call the combine export:

import { featureFlags } from "@workertown/feature-flags";
import { search } from "@workertown/search";
import { combine } from "@workertown/utils/combine";

export default combine(
  featureFlags({ basePath: "/flags" }),
  search({ basePath: "/search" })

// ⬆️ A combined search and Feature Flags API

The combined API will have it's access, auth, logger and sentry options disabled, so these must be configured on the individual services as they apply.

Remember to set the `basePath`!

By default, combined services are mounted at the root of the API (/). If you would like to namespace each service within the combined API, you must set the basePath option for each service.

The example above makes the feature flags endpoints available at /flags/* and the search endpoints available at /search/*.

Search Tutorial
Advanced conceptsTesting

See a problem with this page? Submit an issue