Found class represents a successful HTTP response with status code 302. It is used to standardize "Found" responses, typically for temporary redirects where the resource has been temporarily moved to a different location.ts
import { Found } from "@arkyn/server";
message (required): A message describing the redirect status.body (optional): The response body to include in the HTTP response, which can be any serializable data. This is useful for providing additional information to the client, such as the new location of the resource or instructions for the client on how to proceed.toResponse() - Converts the instance into a Response object with JSON body and Content-Type: application/json header.toJson() - Alternative method using Response.json() for generating the JSON response.typescript
import { Found } from "@arkyn/server";// Basic usage - return the responseconst response = new Found("Resource temporarily moved");return response.toResponse();// With redirect location in bodyreturn new Found("Redirecting to new location", {redirectUrl: "/new-location",}).toResponse();// Using toJson alternativereturn new Found("Temporary redirect", {location: "https://example.com/temporary",}).toJson();
json
{"redirectUrl": "/new-location"}
body parameter is optional. If not provided, the response body will be undefined.