Skip to content

Instantly share code, notes, and snippets.

View jackblanc's full-sized avatar

Jack Blanc jackblanc

View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active November 27, 2025 13:28
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@mattkinnersley
mattkinnersley / auth.$path.tsx
Last active September 27, 2024 01:12
SST Ion Auth + Remix
export async function loader({ request, params }: LoaderFunctionArgs) {
if (params.path === "callback") {
const { searchParams } = new URL(request.url);
const code = searchParams.get("code");
if (code) {
const response = await fetch(import.meta.env.VITE_AUTH_URL + "/token", {
method: "POST",
body: new URLSearchParams({
grant_type: "authorization_code",