From b6ca02a684dbf13a3138b552e2d2be64697f2254 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Fri, 13 Jan 2023 04:20:43 +0100 Subject: [PATCH] docs: links to http status codes (#8480) closes #8264 --- .changeset/mean-pants-destroy.md | 5 +++++ packages/kit/types/index.d.ts | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .changeset/mean-pants-destroy.md diff --git a/.changeset/mean-pants-destroy.md b/.changeset/mean-pants-destroy.md new file mode 100644 index 000000000000..ec044f160744 --- /dev/null +++ b/.changeset/mean-pants-destroy.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +docs: links to http status codes diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 2944b989c348..9924fd438516 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -1080,7 +1080,7 @@ export type ActionResult< * Creates an `HttpError` object with an HTTP status code and an optional message. * This object, if thrown during request handling, will cause SvelteKit to * return an error response without invoking `handleError` - * @param status The HTTP status code + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. * @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property. */ export function error(status: number, body: App.Error): HttpError; @@ -1094,15 +1094,16 @@ export function error( * The object returned by the [`error`](https://kit.svelte.dev/docs/modules#sveltejs-kit-error) function. */ export interface HttpError { - /** The [HTTP status code](https://httpstatusdogs.com), in the range 400-599 */ + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */ status: number; /** The content of the error. */ body: App.Error; } /** - * Create a `Redirect` object. If thrown during request handling, SvelteKit will - * return a redirect response. + * Create a `Redirect` object. If thrown during request handling, SvelteKit will return a redirect response. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages). Must be in the range 300-308. + * @param location The location to redirect to. */ export function redirect( status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308, @@ -1113,7 +1114,7 @@ export function redirect( * The object returned by the [`redirect`](https://kit.svelte.dev/docs/modules#sveltejs-kit-redirect) function */ export interface Redirect { - /** The [HTTP status code](https://httpstatusdogs.com), in the range 300-308. */ + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */ status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308; /** The location to redirect to. */ location: string; @@ -1128,6 +1129,8 @@ export function json(data: any, init?: ResponseInit): Response; /** * Create an `ActionFailure` object. + * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599. + * @param data Data associated with the failure (e.g. validation errors) */ export function fail | undefined>( status: number, @@ -1139,7 +1142,9 @@ export function fail | undefined>( */ export interface ActionFailure | undefined = undefined> extends UniqueInterface { + /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */ status: number; + /** Data associated with the failure (e.g. validation errors) */ data: T; }