Compare commits
No commits in common. "a333b9520d954411d04a2be46794a62aefc6ed02" and "8d20162922ae7a03ea6a2ca5e5bf44f5acffaa2a" have entirely different histories.
a333b9520d
...
8d20162922
1
functions/package-lock.json
generated
1
functions/package-lock.json
generated
@ -10,7 +10,6 @@
|
||||
"dependencies": {
|
||||
"@types/node-fetch": "^2.6.12",
|
||||
"axios": "^1.8.4",
|
||||
"cors": "^2.8.5",
|
||||
"firebase-admin": "^12.6.0",
|
||||
"firebase-functions": "^6.0.1",
|
||||
"form-data": "^4.0.1",
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
"dependencies": {
|
||||
"@types/node-fetch": "^2.6.12",
|
||||
"axios": "^1.8.4",
|
||||
"cors": "^2.8.5",
|
||||
"firebase-admin": "^12.6.0",
|
||||
"firebase-functions": "^6.0.1",
|
||||
"form-data": "^4.0.1",
|
||||
|
||||
@ -8,7 +8,6 @@ import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as https from 'https';
|
||||
import cors from 'cors';
|
||||
import axios from "axios";
|
||||
import { getStorage } from 'firebase-admin/storage';
|
||||
const formData = require('form-data');
|
||||
@ -20,13 +19,9 @@ const twilio = require('twilio');
|
||||
if (!admin.apps.length) {
|
||||
admin.initializeApp();
|
||||
}
|
||||
|
||||
const corsHandler = cors({ origin: true });
|
||||
|
||||
export const sendEmailWithAttachment = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
try {
|
||||
const { toAddress, subject, message, fileUrl, fileName } = request.body;
|
||||
|
||||
@ -83,14 +78,11 @@ export const sendEmailWithAttachment = onRequest({
|
||||
logger.error('Error sending email with attachment from URL:', error);
|
||||
response.status(500).json({ success: false, error: error instanceof Error ? error.message : String(error) });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const accessFile = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
|
||||
try {
|
||||
const filePath = request.query.path as string;
|
||||
if (!filePath) {
|
||||
@ -121,14 +113,11 @@ export const accessFile = onRequest({
|
||||
logger.error('Error accessing file:', error);
|
||||
response.status(500).send('Error accessing file');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const sendEmailMessage = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
|
||||
const mailgun = new Mailgun(formData);
|
||||
const mailGunClient = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
|
||||
|
||||
@ -153,14 +142,11 @@ export const sendEmailMessage = onRequest({
|
||||
logger.error(err);
|
||||
response.send(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export const sendSMSMessage = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
|
||||
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
|
||||
const { to, body } = request.body;
|
||||
client.messages
|
||||
@ -177,7 +163,6 @@ export const sendSMSMessage = onRequest({
|
||||
logger.error('Error sending SMS:', error);
|
||||
response.status(500).json({ success: false, error: error.message });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
interface Invitation {
|
||||
@ -191,7 +176,6 @@ export const notifyInvitation = onDocumentCreated({
|
||||
document: 'notifications/{notificationId}',
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (event: any) => {
|
||||
|
||||
const invitation = event.data?.data() as Invitation;
|
||||
const invitationId = event.params.invitationId;
|
||||
|
||||
@ -261,8 +245,6 @@ export const notifyInvitation = onDocumentCreated({
|
||||
export const createCashfreeOrder = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (request: Request, response: express.Response) => {
|
||||
|
||||
return corsHandler(request, response, async () => {
|
||||
try {
|
||||
const authHeader = request.headers.authorization;
|
||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||
@ -349,14 +331,11 @@ export const createCashfreeOrder = onRequest({
|
||||
details: error.response?.data || error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const verifyCashfreePayment = onRequest({
|
||||
region: '#{SERVICES_RGN}#'
|
||||
}, async (request: Request, response: express.Response) => {
|
||||
return corsHandler(request, response, async () => {
|
||||
|
||||
try {
|
||||
const orderId = request.body.order_id || request.query.order_id;
|
||||
|
||||
@ -408,5 +387,4 @@ export const verifyCashfreePayment = onRequest({
|
||||
details: error.response?.data || error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user