Concepts

Project Structure

Applies to
Gatewayruntime for API, AI, and MCP gateways
Hosting
Managed EdgeManaged DedicatedSelf-Hosted

A Zuplo project is a standard Node.js-style project managed via Git. Here is the typical layout. Select a file to see what it does.

my-api/
my-api/config/routes.oas.json
routes.oas.json
Route definitions in OpenAPI format
Committed
When it's used
Read at build time to create the gateway's routes

An OpenAPI 3.1 document that defines your API routes. Each operation specifies the HTTP method, path, handler, and policies to apply. Zuplo extends the OpenAPI spec with x-zuplo-route to attach a handler and policies to each operation.

Tips
  • Routes match in the order they appear in the file, so put specific paths such as /users/admin before /users/{userId}.
  • With several OpenAPI files, Zuplo checks them in alphabetical order.
  • The same document powers the API reference in your Developer Portal, so add summaries and descriptions as you go.

This route forwards GET /users/{userId} to a backend and runs two policies first:

JSONconfig/routes.oas.json
{ "paths": { "/users/{userId}": { "get": { "operationId": "get-user", "x-zuplo-route": { "corsPolicy": "anything-goes", "handler": { "export": "urlForwardHandler", "module": "$import(@zuplo/runtime)", "options": { "baseUrl": "https://api.example.com" } }, "policies": { "inbound": ["api-key-inbound", "rate-limit-inbound"] } } } } } }

See OpenAPI and Routing for details.

How the files relate

  1. zuplo.jsonc sets project-wide configuration (runtime version, deployment type)
  2. config/routes.oas.json defines API routes and wires each route to a handler and policies by name
  3. config/policies.json defines the named policy instances with their configuration and points to either built-in modules (@zuplo/runtime) or custom modules in ./modules
  4. modules/ contains the TypeScript implementations for custom handlers and policies

All of this lives in Git and deploys automatically when you push.

The $import() syntax

JSON configuration files (routes.oas.json and policies.json) use the $import() syntax to reference code modules. This is a Zuplo-specific syntax that resolves module references at build time.

JSONCode
{ "module": "$import(@zuplo/runtime)" }

References starting with @zuplo/runtime point to built-in Zuplo modules (policies, handlers, and utilities).

JSONCode
{ "module": "$import(./modules/my-handler)" }

References starting with ./modules/ point to your custom TypeScript files in the modules/ directory. The export field specifies which named export to use from that module.

Last modified on