Skip to main content
Version: Next

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

  • BasePart<"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.


fn

fn: Reference<AnyFunction>

Reference to the API's NodeJS implementation.


kind

kind: "api"

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

Inherited from

BasePart.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.


path

path: string

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