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>
This commit is contained in:
20
server/middleware/validate.ts
Normal file
20
server/middleware/validate.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user