Profilbild: zufälliger DiceBear-Avatar (Big Smile) pro Kunde
Der Server erzeugt das SVG lokal unter /api/avatar.svg (Seed = Kunden-ID), es geht also keine Anfrage an dicebear.com. Die Initialen bleiben als Fallback, bis das Bild geladen ist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4efdac226
commit
8c9d28c30f
5 files changed
+70
-2
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import { Router } from 'express'
|
||||
import { createAvatar } from '@dicebear/core'
|
||||
import * as bigSmile from '@dicebear/big-smile'
|
||||
import { config } from '../config.js'
|
||||
import { getSessionCustomerId, requireSession } from '../middleware/session.js'
|
||||
import { getDocument, listDocuments, Query } from '../services/appwriteAdmin.js'
|
||||
@@ -105,4 +107,16 @@ router.get('/contact', requireSession, async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
/** Profilbild: DiceBear "Big Smile", lokal erzeugt (keine Anfrage an dicebear.com).
|
||||
Die Kunden-ID ist der Seed - zufaellig pro Kunde, aber bei jedem Login dasselbe Bild. */
|
||||
router.get('/avatar.svg', requireSession, (req, res) => {
|
||||
const svg = createAvatar(bigSmile, {
|
||||
seed: String(getSessionCustomerId(req) || 'webklar'),
|
||||
backgroundColor: ['b6e3f4', 'c0aede', 'd1d4f9', 'ffd5dc', 'ffdfbf'],
|
||||
}).toString()
|
||||
res.setHeader('Content-Type', 'image/svg+xml; charset=utf-8')
|
||||
res.setHeader('Cache-Control', 'private, max-age=86400')
|
||||
return res.send(svg)
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in new issue
Block a user