import { ReactNode, useEffect, useState } from 'react'
import { createPortal } from 'react-dom'
interface PortalProps {
children: ReactNode
container?: Element
import { Link, useLocation, useMatches } from 'react-router-dom'
interface BreadcrumbMatch {
pathname: string
handle?: {
crumb?: (data?: any) => string
import { NextResponse } from 'next/server';
import { z } from 'zod';
const Body = z.object({ name: z.string().min(2).max(80) });
function getUserId(req: Request) {
export interface Todo {
id: string;
title: string;
done: boolean;
}
import Busboy from 'busboy';
import type { Request, Response } from 'express';
export function upload(req: Request, res: Response) {
const bb = Busboy({ headers: req.headers, limits: { fileSize: 10 * 1024 * 1024 } });
let bytes = 0;
import React, { createContext, useContext, useState, ReactNode } from 'react'
interface TabsContextType {
activeTab: string
setActiveTab: (tab: string) => void
}
import { initTRPC } from '@trpc/server';
import { z } from 'zod';
const t = initTRPC.context<{ userId?: string }>().create();
const authed = t.middleware(({ ctx, next }) => {
if (!ctx.userId) throw new Error('UNAUTHORIZED');
import http from 'node:http';
export function setupGracefulShutdown(server: http.Server, opts?: { timeoutMs?: number }) {
const timeoutMs = opts?.timeoutMs ?? 10_000;
const sockets = new Set<import('node:net').Socket>();
let isShuttingDown = false;
export async function fetchWithTimeout(input: RequestInfo, init: RequestInit & { timeoutMs?: number } = {}) {
const controller = new AbortController();
const timeoutMs = init.timeoutMs ?? 5_000;
const t = setTimeout(() => controller.abort(), timeoutMs);
try {
import { Link } from 'react-router-dom'
import { useQueryClient } from '@tanstack/react-query'
import api from '@/services/api'
import { PostId } from '@/types'
interface PostLinkProps {
import React from 'react'
interface SkeletonProps {
width?: string | number
height?: string | number
className?: string
import { useMutation, useQueryClient } from '@tanstack/react-query';
type Snip = { id: string; liked: boolean; likesCount: number };
export function useToggleLike(snipId: string) {
const qc = useQueryClient();