const express = require('express');
const { toCsv } = require('./csvSerializer');
const { fetchOrders } = require('./orderRepository');
const router = express.Router();
import { Writable } from "node:stream";
import type { Pool } from "pg";
interface Row {
email: string;
name: string;
const { Pool } = require('pg');
const Cursor = require('pg-cursor');
const pool = new Pool();
async function* streamUsers({ since, batchSize = 500 }) {
const Busboy = require('busboy');
const { storeFile } = require('./storage');
function parseMultipart(req, { maxFileSize = 20 * 1024 * 1024 } = {}) {
return new Promise((resolve, reject) => {
const busboy = Busboy({
const sharp = require('sharp');
const DEFAULTS = {
maxWidth: 1600,
maxHeight: 1600,
format: 'webp',
const rawOrigins = process.env.ALLOWED_ORIGINS ?? "";
export const allowedOrigins = new Set(
rawOrigins
.split(",")
.map((o) => o.trim())
class TokenBucket {
constructor(capacity, refillPerSecond) {
this.capacity = capacity;
this.refillPerMs = refillPerSecond / 1000;
this.tokens = capacity;
this.lastRefill = Date.now();
function createReadiness() {
let ready = true;
function markUnready() {
ready = false;
}
const jwt = require('jsonwebtoken');
const SECRET = process.env.JWT_SECRET;
const ALGORITHM = 'HS256';
const ACCESS_TTL = '15m';
const jwt = require('jsonwebtoken');
function authenticate(req, res, next) {
const header = req.headers.authorization || '';
const [scheme, token] = header.split(' ');
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export async function getFeedNaive(limit = 20) {
const posts = await prisma.post.findMany({
const express = require('express');
const { enqueueEmail } = require('./emailQueue');
const router = express.Router();
router.post('/users/:id/welcome-email', async (req, res, next) => {