import { S3Client } from "@aws-sdk/client-s3";
import { createPresignedPost, PresignedPost } from "@aws-sdk/s3-presigned-post";
import { randomUUID } from "crypto";
const s3 = new S3Client({ region: process.env.AWS_REGION });
const BUCKET = process.env.UPLOAD_BUCKET!;
import { WebSocketServer } from 'ws';
import type WebSocket from 'ws';
type ClientState = { topics: Set<string> };
const state = new WeakMap<WebSocket, ClientState>();
import { Request, Response } from 'express';
import { authenticate } from './auth.service';
export async function login(req: Request, res: Response): Promise<void> {
const { email, password } = req.body ?? {};
import { Pool } from "pg";
async function keyFor(pool: Pool, name: string): Promise<string> {
const { rows } = await pool.query<{ key: string }>(
"SELECT hashtextextended($1, 0) AS key",
[name]
import { Prisma, PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
type TxClient = Prisma.TransactionClient;
CREATE TABLE password_reset_tokens (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
token_hash TEXT NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
used_at TIMESTAMPTZ,
import { QueryResultRow } from 'pg';
import { pool, Queryable } from './db';
export abstract class BaseRepository<T extends QueryResultRow> {
protected abstract readonly table: string;