diff --git a/src/app/api/sms/send-notification/route.js b/src/app/api/sms/send-notification/route.js deleted file mode 100644 index 2d4b123a..00000000 --- a/src/app/api/sms/send-notification/route.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @fileoverview SMS notification API endpoint - * Handles sending SMS notifications via Twilio API - */ - -import { NextResponse } from 'next/server'; -import { TwilioSMSProvider } from '@/lib/services/twilio-sms-provider.js'; - -/** - * Send SMS notification - * @param {Object} params - SvelteKit request parameters - * @param {Request} params.request - The request object - */ -export async function POST(request) { - try { - const { phoneNumber, message } = await request.json(); - - if (!phoneNumber || !message) { - return NextResponse.json( - { error: 'Phone number and message are required' }, - { status: 400 } - ); - } - - console.log('📱 [SMS-API] Sending SMS via Twilio:', { - to: phoneNumber, - messageLength: message.length, - timestamp: new Date().toISOString() - }); - - // Initialize Twilio SMS provider - const twilioProvider = new TwilioSMSProvider(); - - // Send SMS via Twilio - const result = await twilioProvider.sendSMS(phoneNumber, message); - - const messageId = (result && typeof result === 'object' && 'messageId' in result) ? result.messageId : 'unknown'; - const status = (result && typeof result === 'object' && 'status' in result) ? result.status : 'sent'; - - console.log('📱 [SMS-API] SMS sent successfully:', { - messageId, - status - }); - - return NextResponse.json({ - success: true, - messageId, - status - }); - - } catch (error) { - console.error('📱 [SMS-API] Error sending SMS:', error); - const errorMessage = error instanceof Error ? error.message : 'Failed to send SMS notification'; - return NextResponse.json( - { error: errorMessage }, - { status: 500 } - ); - } -} \ No newline at end of file diff --git a/src/middleware.js b/src/middleware.js index 7bc62218..70d8b915 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -4,7 +4,7 @@ import { RateLimiter } from '@/lib/server/rate-limiter.js'; const authRateLimiter = new RateLimiter({ maxRequests: 10, windowMs: 60 * 1000 }); const webhookRateLimiter = new RateLimiter({ maxRequests: 100, windowMs: 60 * 1000 }); const apiRateLimiter = new RateLimiter({ maxRequests: 60, windowMs: 60 * 1000 }); -const keyBackupRateLimiter = new RateLimiter({ maxRequests: 5, windowMs: 60 * 60 * 1000 }); +const keyBackupRateLimiter = new RateLimiter({ maxRequests: 10, windowMs: 15 * 60 * 1000 }); function getClientIp(request) { // See the detailed note in src/lib/server/rate-limiter.js.