chore: aktuellen Live-Stand sichern (Admin-API, Services, Auth-Erweiterungen)
Sichert den bisher uncommitteten Produktionsstand des Kundenbereich-Servers, damit kuenftige Deploys (git reset --hard) nichts mehr verwerfen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
53
server/routes/admin/customers.js
Normal file
53
server/routes/admin/customers.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Router } from 'express'
|
||||
import { requireAppwriteStaff } from '../../middleware/appwriteStaff.js'
|
||||
import {
|
||||
createCustomerWithPortalAccess,
|
||||
deleteCustomerWithPortalAccess,
|
||||
listCustomersForAdmin,
|
||||
updateCustomerWithPortalAccess,
|
||||
} from '../../services/customerAdmin.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.use(requireAppwriteStaff)
|
||||
|
||||
router.get('/', async (_req, res) => {
|
||||
try {
|
||||
const customers = await listCustomersForAdmin()
|
||||
return res.json({ customers })
|
||||
} catch (err) {
|
||||
const status = err.status || 500
|
||||
return res.status(status).json({ error: err.message || 'Kunden konnten nicht geladen werden' })
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
const result = await createCustomerWithPortalAccess(req.body || {})
|
||||
return res.status(201).json(result)
|
||||
} catch (err) {
|
||||
const status = err.status || 500
|
||||
return res.status(status).json({ error: err.message || 'Kunde konnte nicht angelegt werden' })
|
||||
}
|
||||
})
|
||||
|
||||
router.patch('/:customerId', async (req, res) => {
|
||||
try {
|
||||
const result = await updateCustomerWithPortalAccess(req.params.customerId, req.body || {})
|
||||
return res.json(result)
|
||||
} catch (err) {
|
||||
const status = err.status || 500
|
||||
return res.status(status).json({ error: err.message || 'Kunde konnte nicht aktualisiert werden' })
|
||||
}
|
||||
})
|
||||
|
||||
router.delete('/:customerId', async (req, res) => {
|
||||
try {
|
||||
return res.json(await deleteCustomerWithPortalAccess(req.params.customerId))
|
||||
} catch (err) {
|
||||
const status = err.status || 500
|
||||
return res.status(status).json({ error: err.message || 'Kunde konnte nicht gelöscht werden' })
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user