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>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
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 projects = await listDocuments(config.collections.websiteProjects, [
|
|
Query.equal('customerId', customerId),
|
|
Query.orderDesc('$createdAt'),
|
|
])
|
|
|
|
const sanitized = projects.map((p) => ({
|
|
id: p.$id,
|
|
projectName: p.projectName || '',
|
|
subdomain: p.subdomain || '',
|
|
previewUrl: p.previewUrl || '',
|
|
liveDomain: p.liveDomain || '',
|
|
status: p.status || '',
|
|
provisioningStatus: p.provisioningStatus || '',
|
|
templateName: p.templateName || '',
|
|
giteaRepoUrl: p.giteaRepoUrl || '',
|
|
repoFullName: p.repoFullName || '',
|
|
}))
|
|
|
|
return res.json({ projects: sanitized })
|
|
} catch (err) {
|
|
return res.status(500).json({ error: err.message || 'Projekte konnten nicht geladen werden' })
|
|
}
|
|
})
|
|
|
|
export default router
|