UNPKG

payload-auth-plugin-fix

Version:
20 lines (18 loc) 540 B
import { ProviderAlreadyExists } from "../core/errors/consoleErrors.js" import { ProvidersConfig } from "../types.js" export function mapProviders(providers: ProvidersConfig[]) { const providerRecords = providers.reduce( (record: Record<string, ProvidersConfig>, provider: ProvidersConfig) => { if (record[provider.id]) { throw new ProviderAlreadyExists() } const newRecord = { ...record, [provider.id]: provider, } return newRecord }, {}, ) return providerRecords }