Added cors createCashfreeOrder (#7)
Reviewed-on: #7 Co-authored-by: DhanshCOSQ <dhanshas@cosq.net> Co-committed-by: DhanshCOSQ <dhanshas@cosq.net>
This commit is contained in:
parent
8d20162922
commit
f6facf40f8
1
functions/package-lock.json
generated
1
functions/package-lock.json
generated
@ -10,6 +10,7 @@
|
|||||||
"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,6 +17,7 @@
|
|||||||
"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,6 +8,7 @@ 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');
|
||||||
@ -19,6 +20,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) => {
|
||||||
@ -245,6 +249,8 @@ 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 ')) {
|
||||||
@ -332,6 +338,7 @@ export const createCashfreeOrder = onRequest({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
export const verifyCashfreePayment = onRequest({
|
export const verifyCashfreePayment = onRequest({
|
||||||
region: '#{SERVICES_RGN}#'
|
region: '#{SERVICES_RGN}#'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user