Skip to main content
Glama
Rana-X
by Rana-X
resend.js1.75 kB
/** * Mock implementation of Resend API for testing * This replaces the real Resend module during tests */ class MockResend { constructor(apiKey) { this.apiKey = apiKey; this.sentEmails = []; this.shouldFail = false; this.failureError = null; } // Mock the emails.send method emails = { send: async (emailData) => { // Store the email data for verification in tests this.sentEmails.push(emailData); // Simulate API key validation if (!this.apiKey || this.apiKey === 'invalid_key') { return { error: { statusCode: 401, name: 'validation_error', message: 'API key is invalid' } }; } // Simulate failure if configured if (this.shouldFail) { return { error: this.failureError || { statusCode: 500, name: 'internal_error', message: 'Failed to send email' } }; } // Simulate successful email send return { data: { id: `mock-email-${Date.now()}`, from: emailData.from, to: emailData.to, subject: emailData.subject }, error: null }; } }; // Helper methods for testing _reset() { this.sentEmails = []; this.shouldFail = false; this.failureError = null; } _setFailure(shouldFail, error = null) { this.shouldFail = shouldFail; this.failureError = error; } _getSentEmails() { return this.sentEmails; } _getLastEmail() { return this.sentEmails[this.sentEmails.length - 1]; } } // Export for both CommonJS and ESM export const Resend = MockResend; export default MockResend;

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/Rana-X/irl'

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