hermes-control-interface icon indicating copy to clipboard operation
hermes-control-interface copied to clipboard

feat(office): Backend Departments API

Open quirinal36 opened this issue 6 months ago • 1 comments

Summary

Office 부서(Department) 데이터를 저장/조회/수정/삭제하는 API를 추가한다.

Changes — server.js

  • officeDepartmentsPath 상수 추가 (CONTROL_HOME/office-departments.json)
  • readOfficeDepartments() / writeOfficeDepartments() 헬퍼 추가 (기존 layout JSON 패턴과 동일)
  • 4개 라우트 추가:
    • GET /api/office/departments — requireAuth
    • POST /api/office/departments — requireRole('admin') + requireCsrf, body: {name, color}
    • DELETE /api/office/departments/:id — requireRole('admin') + requireCsrf
    • PUT /api/office/departments/:id/members — requireRole('admin') + requireCsrf, body: {members: []}

Security

  • name: 40자 trim
  • color: /^#[0-9a-fA-F]{6}$/ 검증
  • id: /^[a-f0-9]{12}$/ 검증
  • members: sanitizeProfileName() 통과

Test

# Create
curl -X POST /api/office/departments -H 'Content-Type: application/json' -d '{"name":"Engineering","color":"#7c945c"}'
# List
curl /api/office/departments
# Add member
curl -X PUT /api/office/departments/:id/members -d '{"members":["default"]}'
# Delete
curl -X DELETE /api/office/departments/:id

quirinal36 avatar May 05 '26 08:05 quirinal36

Closed by merge commit e4b31af (PR #60 — office visualization with departments + Playwright e2e tests)

xaspx avatar May 10 '26 20:05 xaspx