Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
whimet committed Nov 7, 2023
1 parent 401b63b commit 170c445
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions firebase-functions/paddle-webhook/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const db = admin.firestore();
const webhook = require('./webhook');
const alertParser = require('./alert_parser');
const pubKey = functions.config().paddle.pub_key;
const http = require('http');
const https = require('https');

exports.info = functions.https.onRequest((req, res) => {
res.send(`Hello from ${process.env.GCLOUD_PROJECT}!`);
Expand All @@ -30,17 +30,19 @@ exports.sync_diagram = functions.https.onRequest(async (req, res) => {

const options = {
hostname: process.env.LARASITE_HOST || 'sequence-diagram.zenuml.com',
port: process.env.LARASITE_PORT || 80,
port: process.env.LARASITE_PORT || 443,
path: '/diagrams',
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
const data = JSON.stringify({token: req.body.token, user, firebase_diagram_id: req.body.id, name: req.body.name, content: req.body.content, description: req.body.description,imageBase64: req.body.imageBase64});
console.log('http request with:', options, data);
console.log('request - options: ', options, 'data: ', data);

const request = https.request(options, (response) => {
console.log(`response - code: ${response.statusCode}, headers: `, response.headers);

const request = http.request(options, (response) => {
let responseData = '';
response.on('data', (chunk) => {
responseData += chunk;
Expand All @@ -52,7 +54,7 @@ exports.sync_diagram = functions.https.onRequest(async (req, res) => {
});

request.on('error', (error) => {
console.error(error);
console.error('request failed: ', error);
res.send(error);
});

Expand Down

0 comments on commit 170c445

Please sign in to comment.