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
ensureMongoDocumentToObject.ts•699 B
import type { Document, ObjectIdToString } from 'mongoose';
/**
* If the dictionary is a mongoose document, convert it to an object
* @param potentialDocument - The potential document to convert.
* @returns The potential document converted to an object.
*/
export const ensureMongoDocumentToObject = <T extends object | Document>(
potentialDocument: T
): ObjectIdToString<T> => {
let potentialObject: T = potentialDocument as T;
// If the user is a mongoose document, convert it to an object
if (typeof (potentialDocument as Document).toObject === 'function') {
potentialObject = (potentialDocument as Document).toObject();
}
return potentialObject as ObjectIdToString<T>;
};