Last active
September 2, 2022 02:58
-
-
Save danieljpgo/cfccdd477e0397688f327358b6c10d71 to your computer and use it in GitHub Desktop.
/lib/remix.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a response with a permanently redirect using `301` as status code. | |
*/ | |
export function redirectPermanently( | |
url: string, | |
init?: Omit<ResponseInit, "status"> | |
) { | |
return redirect(url, { ...init, status: 301 }); | |
} | |
/** | |
* Create a response with a Not Found error using `404` as status code. | |
*/ | |
export function notFound(init?: Omit<ResponseInit, "status">) { | |
return json("Not Found", { ...init, status: 404 }); | |
} | |
/** | |
* Create a response receiving a JSON object with the status code 400. | |
*/ | |
export function badRequest<Data = unknown>( | |
data: Data, | |
init?: Omit<ResponseInit, "status"> | |
) { | |
return json<Data>(data, { ...init, status: 400 }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment