wing-ops/backend/src/settings/settingsRouter.ts
htlee a0f64e4b11 style: 기존 코드 ESLint/TypeScript 에러 수정
- frontend: ESLint 에러 86건 수정 (unused-vars, set-state-in-effect, static-components 등)
- backend: simulation.ts req.params 타입 단언 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 15:47:29 +09:00

50 lines
1.5 KiB
TypeScript

import { Router } from 'express'
import { requireAuth, requireRole } from '../auth/authMiddleware.js'
import {
getRegistrationSettings,
updateRegistrationSettings,
getAllSettings,
} from './settingsService.js'
const router = Router()
router.use(requireAuth)
router.use(requireRole('ADMIN'))
// GET /api/settings — 전체 설정 조회
router.get('/', async (_req, res) => {
try {
const settings = await getAllSettings()
res.json(settings)
} catch (err) {
console.error('[settings] 조회 오류:', err)
res.status(500).json({ error: '설정 조회 중 오류가 발생했습니다.' })
}
})
// GET /api/settings/registration — 가입 설정 조회
router.get('/registration', async (_req, res) => {
try {
const settings = await getRegistrationSettings()
res.json(settings)
} catch (err) {
console.error('[settings] 가입 설정 조회 오류:', err)
res.status(500).json({ error: '가입 설정 조회 중 오류가 발생했습니다.' })
}
})
// PUT /api/settings/registration — 가입 설정 수정
router.put('/registration', async (req, res) => {
try {
const { autoApprove, defaultRole } = req.body
await updateRegistrationSettings({ autoApprove, defaultRole })
const updated = await getRegistrationSettings()
res.json(updated)
} catch (err) {
console.error('[settings] 가입 설정 수정 오류:', err)
res.status(500).json({ error: '가입 설정 수정 중 오류가 발생했습니다.' })
}
})
export default router