Skip to main content
Glama
user.ts1.04 kB
import { ensureMongoDocumentToObject } from '@utils/ensureMongoDocumentToObject'; import type { User, UserAPI } from '@/types/user.types'; /** * Formats a user for API response. Removes sensitive information and adds role. * @param user - The user object to format. * @returns The formatted user object. */ export const mapUserToAPI = <T extends User | UserAPI | null>( user?: T ): T extends null ? null : UserAPI => { if (!user) { return null as any; } const userObject = ensureMongoDocumentToObject(user); // biome-ignore lint/correctness/noUnusedVariables: Just filter out provider and session const { provider, session, ...userAPI } = userObject as any; return userAPI as any; }; /** * Formats an array of users for API response. Removes sensitive information and adds role. * @param users - The array of user objects to format. * @returns The formatted array of user objects. */ export const mapUsersToAPI = (users: (User | UserAPI)[]): UserAPI[] => users.map(mapUserToAPI).filter(Boolean) as UserAPI[];

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server