Skip to main content
Version: 0.24

Interface: Api

A custom HTTP endpoint mounted on the Wasp server.

Create one with the api constructor.

Unlike operations, APIs are plain Express handlers that receive req, res, and a Wasp context. They are useful for webhooks and any non-standard HTTP interaction.

See Custom HTTP API Endpoints.

Extends

  • BaseSpecElement<"api">

Properties

auth?

optional auth?: boolean

If true, the handler requires the request to come from an authenticated user and receives context.user. Defaults to true when the app has auth enabled, and false otherwise. Set to false to skip parsing the JWT from the Authorization header.


entities?

optional entities?: string[]

Entities the handler operates on. Wasp injects a Prisma delegate for each one into the handler's context.entities.

See Using Entities in APIs.


fn

fn: Reference<AnyFunction>

Reference to the API's NodeJS implementation.


kind

kind: "api"

The internal Wasp type of a SpecElement. Used by the compiler. You should not set this field directly, instead use the dedicated constructors.

Inherited from

BaseSpecElement.kind


method

method: HttpMethod

HTTP method this endpoint responds to.


middlewareConfigFn?

optional middlewareConfigFn?: Reference<AnyFunction>

Reference to an Express middleware config function for this endpoint only.

See Configuring API middleware.


path

path: string

Express path of the endpoint (e.g. "/webhooks/stripe").