import { ConnectorMetadata } from '@logto/connector-types'; import { getConnectorInstances } from '@/connectors'; import { findDefaultSignInExperience } from '@/queries/sign-in-experience'; import { AnonymousRouter } from './types'; export default function signInSettingsRoutes(router: T) { router.get('/sign-in-settings', async (ctx, next) => { const [signInExperience, connectorInstances] = await Promise.all([ findDefaultSignInExperience(), getConnectorInstances(), ]); const socialConnectors = signInExperience.socialSignInConnectorTargets.reduce< Array >((previous, connectorTarget) => { const connectors = connectorInstances.filter( ({ metadata: { target } }) => target === connectorTarget ); return [ ...previous, ...connectors.map(({ metadata, connector: { id } }) => ({ ...metadata, id })), ]; }, []); ctx.body = { ...signInExperience, socialConnectors }; return next(); }); }