Implementiere Kundenportal mit zentraler Appwrite-Anbindung.
Express-Server für Appwrite-Auth, Session, Projekt-Dashboard und Gitea-Webhook; statisches Frontend und Schema-Dokumentation für woms-database. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
server/routes/features.js
Normal file
36
server/routes/features.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Router } from 'express'
|
||||
import { Query } from 'node-appwrite'
|
||||
import { config } from '../config.js'
|
||||
import { listDocuments } from '../services/appwriteAdmin.js'
|
||||
import { getSessionCustomerId, requireSession } from '../middleware/session.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.get('/', requireSession, async (req, res) => {
|
||||
const customerId = getSessionCustomerId(req)
|
||||
if (!customerId) {
|
||||
return res.status(401).json({ error: 'Nicht angemeldet' })
|
||||
}
|
||||
|
||||
try {
|
||||
const features = await listDocuments(config.collections.portalFeatures, [
|
||||
Query.equal('customerId', customerId),
|
||||
Query.equal('enabled', true),
|
||||
])
|
||||
|
||||
const sanitized = features.map((f) => ({
|
||||
id: f.$id,
|
||||
projectId: f.projectId || '',
|
||||
featureKey: f.featureKey || '',
|
||||
enabled: Boolean(f.enabled),
|
||||
unlockedByPurchase: Boolean(f.unlockedByPurchase),
|
||||
purchaseStatus: f.purchaseStatus || '',
|
||||
}))
|
||||
|
||||
return res.json({ features: sanitized })
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: err.message || 'Features konnten nicht geladen werden' })
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user