Files
antonym/server/middleware/validate.ts
Dorian 54500a68e6 feat: scaffold Antonym fashion store
Anonymous Bitcoin-only fashion e-commerce with:
- Vue 3 + Tailwind 4 frontend with glassmorphism dark/light design system
- Express 5 + SQLite backend with BTCPay Server integration
- Nostr identity (NIP-07/keypair) for anonymous purchase tracking
- ChaCha20-Poly1305 encrypted shipping addresses
- Admin panel with order/product/stock management
- SVG logo splash animation with clip-path reveal
- 5 seeded products across 4 categories

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 00:23:21 +00:00

21 lines
735 B
TypeScript

import type { Request, Response, NextFunction } from 'express'
export function requireBody(...fields: string[]) {
return (req: Request, res: Response, next: NextFunction): void => {
const missing = fields.filter((f) => req.body[f] === undefined || req.body[f] === null)
if (missing.length > 0) { res.status(400).json({ error: { code: 'MISSING_FIELDS', message: `Missing required fields: ${missing.join(', ')}` } }); return }
next()
}
}
export function sanitizeString(val: unknown): string {
if (typeof val !== 'string') return ''
return val.trim().slice(0, 10_000)
}
export function sanitizeInt(val: unknown): number | null {
const n = Number(val)
if (!Number.isInteger(n) || n < 0) return null
return n
}