Skip to content

Commit b6ca02a

Browse files
authored
docs: links to http status codes (#8480)
closes #8264
1 parent 130abe4 commit b6ca02a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

.changeset/mean-pants-destroy.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
docs: links to http status codes

packages/kit/types/index.d.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ export type ActionResult<
10801080
* Creates an `HttpError` object with an HTTP status code and an optional message.
10811081
* This object, if thrown during request handling, will cause SvelteKit to
10821082
* return an error response without invoking `handleError`
1083-
* @param status The HTTP status code
1083+
* @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.
10841084
* @param body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
10851085
*/
10861086
export function error(status: number, body: App.Error): HttpError;
@@ -1094,15 +1094,16 @@ export function error(
10941094
* The object returned by the [`error`](https://kit.svelte.dev/docs/modules#sveltejs-kit-error) function.
10951095
*/
10961096
export interface HttpError {
1097-
/** The [HTTP status code](https://httpstatusdogs.com), in the range 400-599 */
1097+
/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */
10981098
status: number;
10991099
/** The content of the error. */
11001100
body: App.Error;
11011101
}
11021102

11031103
/**
1104-
* Create a `Redirect` object. If thrown during request handling, SvelteKit will
1105-
* return a redirect response.
1104+
* Create a `Redirect` object. If thrown during request handling, SvelteKit will return a redirect response.
1105+
* @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.
1106+
* @param location The location to redirect to.
11061107
*/
11071108
export function redirect(
11081109
status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308,
@@ -1113,7 +1114,7 @@ export function redirect(
11131114
* The object returned by the [`redirect`](https://kit.svelte.dev/docs/modules#sveltejs-kit-redirect) function
11141115
*/
11151116
export interface Redirect {
1116-
/** The [HTTP status code](https://httpstatusdogs.com), in the range 300-308. */
1117+
/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */
11171118
status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;
11181119
/** The location to redirect to. */
11191120
location: string;
@@ -1128,6 +1129,8 @@ export function json(data: any, init?: ResponseInit): Response;
11281129

11291130
/**
11301131
* Create an `ActionFailure` object.
1132+
* @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.
1133+
* @param data Data associated with the failure (e.g. validation errors)
11311134
*/
11321135
export function fail<T extends Record<string, unknown> | undefined>(
11331136
status: number,
@@ -1139,7 +1142,9 @@ export function fail<T extends Record<string, unknown> | undefined>(
11391142
*/
11401143
export interface ActionFailure<T extends Record<string, unknown> | undefined = undefined>
11411144
extends UniqueInterface {
1145+
/** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses), in the range 400-599. */
11421146
status: number;
1147+
/** Data associated with the failure (e.g. validation errors) */
11431148
data: T;
11441149
}
11451150

0 commit comments

Comments
 (0)