import { FixedSizeList as List } from 'react-window'
import AutoSizer from 'react-virtualized-auto-sizer'
import { Post } from '@/types'
import { PostCard } from './PostCard'
interface VirtualizedPostListProps {
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import crypto from 'node:crypto';
const s3 = new S3Client({ region: process.env.AWS_REGION });
import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react'
type Theme = 'light' | 'dark'
interface ThemeContextType {
theme: Theme
import { WebSocketServer } from 'ws';
import type WebSocket from 'ws';
type ClientState = { topics: Set<string> };
const state = new WeakMap<WebSocket, ClientState>();
export interface Cursor {
createdAt: string;
id: string;
}
export function encodeCursor(c: Cursor): string {
import { useState } from 'react'
import {
DndContext,
closestCenter,
KeyboardSensor,
PointerSensor,
import { useForm } from 'react-hook-form';
import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
const Schema = z.object({ title: z.string().min(2).max(120) });
type Form = z.infer<typeof Schema>;
export const Flags = {
NEW_EDITOR: 'new_editor',
FAST_SEARCH: 'fast_search',
BILLING_V2: 'billing_v2'
} as const;
import type { RequestHandler } from 'express';
import crypto from 'node:crypto';
export function weakEtag(value: string) {
const hash = crypto.createHash('sha1').update(value).digest('hex');
return `W/"${hash}"`;
import argon2 from 'argon2';
export async function hashPassword(password: string) {
return argon2.hash(password, { type: argon2.argon2id });
}
import { withClient } from './pool';
export async function withAdvisoryLock(key: string, fn: () => Promise<void>) {
const lockId = Array.from(key).reduce((acc, c) => (acc * 31 + c.charCodeAt(0)) >>> 0, 0);
return withClient(async (client) => {
const got = await client.query('SELECT pg_try_advisory_lock($1) AS got', [lockId]);
import { Suspense } from 'react'
import { useSuspenseQuery } from '@tanstack/react-query'
import { useParams } from 'react-router-dom'
import api from '@/services/api'
import { Post } from '@/types'
import { ErrorBoundary } from '@/components/ErrorBoundary'