Compare commits
No commits in common. "b4a75f4968408de62aa0e2b70972d4861406c183" and "f9930b143c0bfdb03b29c026ed250a75406e0d91" have entirely different histories.
b4a75f4968
...
f9930b143c
@ -9,7 +9,7 @@ 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 axios from "axios";
|
import axios from "axios";
|
||||||
import { getStorage } from 'firebase-admin/storage';
|
|
||||||
const formData = require('form-data');
|
const formData = require('form-data');
|
||||||
const Mailgun = require('mailgun.js');
|
const Mailgun = require('mailgun.js');
|
||||||
const { convert } = require('html-to-text');
|
const { convert } = require('html-to-text');
|
||||||
@ -79,44 +79,8 @@ 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({
|
|
||||||
region: '#{SERVICES_RGN}#'
|
|
||||||
}, async (request: Request, response: express.Response) => {
|
|
||||||
try {
|
|
||||||
const filePath = request.query.path as string;
|
|
||||||
if (!filePath) {
|
|
||||||
response.status(400).send('File path is required');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const expirationMs = 60 * 60 * 1000;
|
|
||||||
|
|
||||||
const bucket = getStorage().bucket();
|
|
||||||
const file = bucket.file(filePath);
|
|
||||||
|
|
||||||
const [exists] = await file.exists();
|
|
||||||
if (!exists) {
|
|
||||||
response.status(404).send('File not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [signedUrl] = await file.getSignedUrl({
|
|
||||||
action: 'read',
|
|
||||||
expires: Date.now() + expirationMs,
|
|
||||||
responseDisposition: `attachment; filename="${path.basename(filePath)}"`,
|
|
||||||
});
|
|
||||||
|
|
||||||
response.redirect(signedUrl);
|
|
||||||
logger.info(`File access redirect for ${filePath}`);
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('Error accessing file:', error);
|
|
||||||
response.status(500).send('Error accessing file');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const sendEmailMessage = onRequest({
|
export const sendEmailMessage = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: process.env.SERVICES_RGN
|
||||||
}, (request: Request, response: express.Response) => {
|
}, (request: Request, response: express.Response) => {
|
||||||
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 });
|
||||||
@ -145,7 +109,7 @@ export const sendEmailMessage = onRequest({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const sendSMSMessage = onRequest({
|
export const sendSMSMessage = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: process.env.SERVICES_RGN
|
||||||
}, (request: Request, response: express.Response) => {
|
}, (request: Request, response: express.Response) => {
|
||||||
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;
|
||||||
@ -174,7 +138,7 @@ interface Invitation {
|
|||||||
|
|
||||||
export const notifyInvitation = onDocumentCreated({
|
export const notifyInvitation = onDocumentCreated({
|
||||||
document: 'notifications/{notificationId}',
|
document: 'notifications/{notificationId}',
|
||||||
region: '#{SERVICES_RGN}#'
|
region: process.env.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;
|
||||||
@ -243,7 +207,7 @@ export const notifyInvitation = onDocumentCreated({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const createCashfreeOrder = onRequest({
|
export const createCashfreeOrder = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: process.env.SERVICES_RGN
|
||||||
}, async (request: Request, response: express.Response) => {
|
}, async (request: Request, response: express.Response) => {
|
||||||
try {
|
try {
|
||||||
const authHeader = request.headers.authorization;
|
const authHeader = request.headers.authorization;
|
||||||
@ -334,7 +298,7 @@ export const createCashfreeOrder = onRequest({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const verifyCashfreePayment = onRequest({
|
export const verifyCashfreePayment = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: process.env.SERVICES_RGN
|
||||||
}, async (request: Request, response: express.Response) => {
|
}, async (request: Request, response: express.Response) => {
|
||||||
try {
|
try {
|
||||||
const orderId = request.body.order_id || request.query.order_id;
|
const orderId = request.body.order_id || request.query.order_id;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user