Compare commits
No commits in common. "0be5cfe30cd631535dc1354346f74db2560f92e3" and "688619bd4529f50d68e36fba07ca533bf85c50b5" have entirely different histories.
0be5cfe30c
...
688619bd45
1
functions/package-lock.json
generated
1
functions/package-lock.json
generated
@ -10,7 +10,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"axios": "^1.8.4",
|
"axios": "^1.8.4",
|
||||||
"cors": "^2.8.5",
|
|
||||||
"firebase-admin": "^12.6.0",
|
"firebase-admin": "^12.6.0",
|
||||||
"firebase-functions": "^6.0.1",
|
"firebase-functions": "^6.0.1",
|
||||||
"form-data": "^4.0.1",
|
"form-data": "^4.0.1",
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node-fetch": "^2.6.12",
|
"@types/node-fetch": "^2.6.12",
|
||||||
"axios": "^1.8.4",
|
"axios": "^1.8.4",
|
||||||
"cors": "^2.8.5",
|
|
||||||
"firebase-admin": "^12.6.0",
|
"firebase-admin": "^12.6.0",
|
||||||
"firebase-functions": "^6.0.1",
|
"firebase-functions": "^6.0.1",
|
||||||
"form-data": "^4.0.1",
|
"form-data": "^4.0.1",
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import * as os from 'os';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
import cors from 'cors';
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { getStorage } from 'firebase-admin/storage';
|
import { getStorage } from 'firebase-admin/storage';
|
||||||
const formData = require('form-data');
|
const formData = require('form-data');
|
||||||
@ -20,13 +19,9 @@ const twilio = require('twilio');
|
|||||||
if (!admin.apps.length) {
|
if (!admin.apps.length) {
|
||||||
admin.initializeApp();
|
admin.initializeApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
const corsHandler = cors({ origin: true });
|
|
||||||
|
|
||||||
export const sendEmailWithAttachment = onRequest({
|
export const sendEmailWithAttachment = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, async (request: Request, response: express.Response) => {
|
}, async (request: Request, response: express.Response) => {
|
||||||
return corsHandler(request, response, async () => {
|
|
||||||
try {
|
try {
|
||||||
const { toAddress, subject, message, fileUrl, fileName } = request.body;
|
const { toAddress, subject, message, fileUrl, fileName } = request.body;
|
||||||
|
|
||||||
@ -84,13 +79,10 @@ export const sendEmailWithAttachment = onRequest({
|
|||||||
response.status(500).json({ success: false, error: error instanceof Error ? error.message : String(error) });
|
response.status(500).json({ success: false, error: error instanceof Error ? error.message : String(error) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
export const accessFile = onRequest({
|
export const accessFile = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, async (request: Request, response: express.Response) => {
|
}, async (request: Request, response: express.Response) => {
|
||||||
return corsHandler(request, response, async () => {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filePath = request.query.path as string;
|
const filePath = request.query.path as string;
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
@ -122,13 +114,10 @@ export const accessFile = onRequest({
|
|||||||
response.status(500).send('Error accessing file');
|
response.status(500).send('Error accessing file');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
export const sendEmailMessage = onRequest({
|
export const sendEmailMessage = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, (request: Request, response: express.Response) => {
|
}, (request: Request, response: express.Response) => {
|
||||||
return corsHandler(request, response, async () => {
|
|
||||||
|
|
||||||
const mailgun = new Mailgun(formData);
|
const mailgun = new Mailgun(formData);
|
||||||
const mailGunClient = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
|
const mailGunClient = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
|
||||||
|
|
||||||
@ -154,13 +143,10 @@ export const sendEmailMessage = onRequest({
|
|||||||
response.send(err);
|
response.send(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
export const sendSMSMessage = onRequest({
|
export const sendSMSMessage = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, (request: Request, response: express.Response) => {
|
}, (request: Request, response: express.Response) => {
|
||||||
return corsHandler(request, response, async () => {
|
|
||||||
|
|
||||||
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
|
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
|
||||||
const { to, body } = request.body;
|
const { to, body } = request.body;
|
||||||
client.messages
|
client.messages
|
||||||
@ -178,7 +164,6 @@ export const sendSMSMessage = onRequest({
|
|||||||
response.status(500).json({ success: false, error: error.message });
|
response.status(500).json({ success: false, error: error.message });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
interface Invitation {
|
interface Invitation {
|
||||||
email: string;
|
email: string;
|
||||||
@ -191,7 +176,6 @@ export const notifyInvitation = onDocumentCreated({
|
|||||||
document: 'notifications/{notificationId}',
|
document: 'notifications/{notificationId}',
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, async (event: any) => {
|
}, async (event: any) => {
|
||||||
|
|
||||||
const invitation = event.data?.data() as Invitation;
|
const invitation = event.data?.data() as Invitation;
|
||||||
const invitationId = event.params.invitationId;
|
const invitationId = event.params.invitationId;
|
||||||
|
|
||||||
@ -261,8 +245,6 @@ export const notifyInvitation = onDocumentCreated({
|
|||||||
export const createCashfreeOrder = onRequest({
|
export const createCashfreeOrder = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, async (request: Request, response: express.Response) => {
|
}, async (request: Request, response: express.Response) => {
|
||||||
|
|
||||||
return corsHandler(request, response, async () => {
|
|
||||||
try {
|
try {
|
||||||
const authHeader = request.headers.authorization;
|
const authHeader = request.headers.authorization;
|
||||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||||
@ -350,13 +332,10 @@ export const createCashfreeOrder = onRequest({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
export const verifyCashfreePayment = onRequest({
|
export const verifyCashfreePayment = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
}, async (request: Request, response: express.Response) => {
|
}, async (request: Request, response: express.Response) => {
|
||||||
return corsHandler(request, response, async () => {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const orderId = request.body.order_id || request.query.order_id;
|
const orderId = request.body.order_id || request.query.order_id;
|
||||||
|
|
||||||
@ -409,4 +388,3 @@ export const verifyCashfreePayment = onRequest({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user