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:
51
server/routes/admin/employees.js
Normal file
51
server/routes/admin/employees.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Router } from 'express'
|
||||
import { requireAppwriteStaff } from '../../middleware/appwriteStaff.js'
|
||||
import {
|
||||
createEmployeeWithLogin,
|
||||
deleteEmployeeWithLogin,
|
||||
listEmployeesForAdmin,
|
||||
updateEmployeeWithLogin,
|
||||
} from '../../services/employeeAdmin.js'
|
||||
|
||||
const router = Router()
|
||||
router.use(requireAppwriteStaff)
|
||||
|
||||
router.get('/', async (_req, res) => {
|
||||
try {
|
||||
return res.json({ employees: await listEmployeesForAdmin() })
|
||||
} catch (error) {
|
||||
return res.status(error.status || 500).json({ error: error.message })
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
try {
|
||||
return res.status(201).json(await createEmployeeWithLogin(req.body || {}))
|
||||
} catch (error) {
|
||||
return res.status(error.status || 500).json({ error: error.message })
|
||||
}
|
||||
})
|
||||
|
||||
router.patch('/:employeeId', async (req, res) => {
|
||||
try {
|
||||
return res.json(await updateEmployeeWithLogin(
|
||||
req.params.employeeId,
|
||||
req.body || {},
|
||||
req.appwriteUser.$id
|
||||
))
|
||||
} catch (error) {
|
||||
return res.status(error.status || 500).json({ error: error.message })
|
||||
}
|
||||
})
|
||||
|
||||
router.delete('/:employeeId', async (req, res) => {
|
||||
try {
|
||||
return res.json(
|
||||
await deleteEmployeeWithLogin(req.params.employeeId, req.appwriteUser.$id)
|
||||
)
|
||||
} catch (error) {
|
||||
return res.status(error.status || 500).json({ error: error.message })
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user