import { createError } from 'h3' import { formatSignupBlockedUsernameMessage, getSignupBlockedUsernameMatch } from '../../lib/signup-blocked-usernames.js' import { getSiteSettings } from '../repositories/content-repository.js' /** * 가입·프로필 변경 시 닉네임이 금지 목록에 해당하는지 검사한다. * @param {string} username - 닉네임 * @returns {Promise} */ export const assertSignupUsernameAllowed = async (username) => { const settings = await getSiteSettings() const match = getSignupBlockedUsernameMatch(username, settings.signupBlockedUsernames || []) if (match) { throw createError({ statusCode: 400, message: formatSignupBlockedUsernameMessage(match) }) } }