ApiModule
The module of an API route: HTTP-method exports and no default export.
The module of an API route: HTTP-method exports and no default export. csrf: false opts the
route out of the CSRF check, for webhooks that authenticate by signature.
Import#
ts
import type { ApiModule } from "@shadow-js/dusk/server";
Signature#
ts
interface ApiModule {
readonly GET?: ApiHandler | undefined;
readonly HEAD?: ApiHandler | undefined;
readonly POST?: ApiHandler | undefined;
readonly PUT?: ApiHandler | undefined;
readonly PATCH?: ApiHandler | undefined;
readonly DELETE?: ApiHandler | undefined;
readonly OPTIONS?: ApiHandler | undefined;
/**
* Answers every method the module does not export by name (HEAD and OPTIONS included). An explicit method export
* wins over it. Unknown method tokens (TRACE, PURGE) are never answered by it: they get 501.
*/
readonly ALL?: ApiHandler | undefined;
readonly csrf?: boolean | undefined;
/** Middleware that wraps every method of the route, after the app-wide middleware. */
readonly middleware?: readonly Middleware[] | undefined;
}
Members#
| Name | Type | Description |
|---|---|---|
GET? |
readonly GET?: ApiHandler | undefined |
|
HEAD? |
readonly HEAD?: ApiHandler | undefined |
|
POST? |
readonly POST?: ApiHandler | undefined |
|
PUT? |
readonly PUT?: ApiHandler | undefined |
|
PATCH? |
readonly PATCH?: ApiHandler | undefined |
|
DELETE? |
readonly DELETE?: ApiHandler | undefined |
|
OPTIONS? |
readonly OPTIONS?: ApiHandler | undefined |
|
ALL? |
readonly ALL?: ApiHandler | undefined |
Answers every method the module does not export by name (HEAD and OPTIONS included). An explicit method export wins over it. Unknown method tokens (TRACE, PURGE) are never answered by it: they get 501. |
csrf? |
readonly csrf?: boolean | undefined |
|
middleware? |
readonly middleware?: readonly Middleware[] | undefined |
Middleware that wraps every method of the route, after the app-wide middleware. |