* Substitutes variable placeholders in text with their actual values * Variables are referenced using %key% syntax
(text: string, variables: Record<string, string> | undefined)
| 75 | * Variables are referenced using %key% syntax |
| 76 | */ |
| 77 | function substituteVariables(text: string, variables: Record<string, string> | undefined): string { |
| 78 | if (!variables) return text |
| 79 | |
| 80 | let result = text |
| 81 | for (const [key, value] of Object.entries(variables)) { |
| 82 | const placeholder = `%${key}%` |
| 83 | result = result.split(placeholder).join(value) |
| 84 | } |
| 85 | return result |
| 86 | } |
| 87 | |
| 88 | export const POST = withRouteHandler(async (request: NextRequest) => { |
| 89 | const auth = await checkInternalAuth(request) |