Found class represents a successful HTTP response with status code 302. It is used to standardize "Found" responses, where the requested resource was located and is included directly in the response body.ts
import { Found } from "@arkyn/server/found";
message (required): A message describing the status.body (optional): The response body to include in the HTTP response, which can be any serializable data. This is where the found resource itself is typically included.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/found";// Basic usage - return the responseconst response = new Found("Resource located");return response.toResponse();// With the found resource in the bodyreturn new Found("Products retrieved", {products,}).toResponse();// Using toJson alternativereturn new Found("User located", {user,}).toJson();
json
{"products": []}
body parameter is optional. If not provided, the response body will be undefined.Location header, it returns the found resource directly in the JSON body with a 302 status, rather than performing a browser-level redirect.Success (200) response.