function sanitizeString(value) {
    if (typeof value !== 'string') return ''
    return value.replace(/[<>\\]/g, '').trim()
}

function sanitizePayload(payload = {}) {
    return Object.keys(payload).reduce((acc, key) => {
        const value = payload[key]
        acc[key] = typeof value === 'string' ? sanitizeString(value) : value
        return acc
    }, {})
}

module.exports = {
    sanitizeString,
    sanitizePayload,
}
