- 5 SVG placeholder product images (minimal dark style with watermark initials) - Seed data updated to reference .svg placeholders - Nostr DM inbox in admin (Messages tab) with shop npub display - GET /api/admin/nostr-info endpoint for shop pubkey - My Orders page: customers look up orders by NIP-07 Nostr identity - GET /api/orders/by-pubkey/:pubkey endpoint with hex validation - SeoMeta component for OG/Twitter meta tags - SEO meta on HomeView and ProductView - Base OG meta tags in index.html - "My Orders" link in shop header nav - Splash logo doubled in size on desktop (680px max) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Router } from 'express'
|
|
import { getDb } from '../db/connection.js'
|
|
import type { OrderItem, OrderStatus } from '../../shared/types.js'
|
|
|
|
export const ordersByPubkeyRouter = Router()
|
|
|
|
interface OrderRow {
|
|
id: string
|
|
nostr_pubkey: string | null
|
|
email: string | null
|
|
btcpay_invoice_id: string | null
|
|
status: string
|
|
items: string
|
|
total_sats: number
|
|
note: string | null
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
ordersByPubkeyRouter.get('/:pubkey', (req, res) => {
|
|
const pubkey = req.params.pubkey
|
|
|
|
if (!/^[0-9a-f]{64}$/.test(pubkey)) {
|
|
res.status(400).json({ error: { code: 'INVALID_PUBKEY', message: 'Invalid hex pubkey' } })
|
|
return
|
|
}
|
|
|
|
const db = getDb()
|
|
const rows = db.prepare(
|
|
'SELECT * FROM orders WHERE nostr_pubkey = ? ORDER BY created_at DESC'
|
|
).all(pubkey) as OrderRow[]
|
|
|
|
res.json(rows.map((row) => ({
|
|
id: row.id,
|
|
nostrPubkey: row.nostr_pubkey,
|
|
email: row.email,
|
|
btcpayInvoiceId: row.btcpay_invoice_id,
|
|
status: row.status as OrderStatus,
|
|
items: JSON.parse(row.items) as OrderItem[],
|
|
totalSats: row.total_sats,
|
|
note: row.note,
|
|
createdAt: row.created_at,
|
|
updatedAt: row.updated_at,
|
|
})))
|
|
})
|