Skip to content

Commit a140ebf

Browse files
authored
Merge pull request #11 from oslabs-beta/dev
Dev merge to Main
2 parents 0ac050b + e669001 commit a140ebf

33 files changed

+1127
-515
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React, { useState } from 'react';
22
import { useSelector, useDispatch } from 'react-redux';
3-
import { RootState } from '../../../toolkit-refactor/store';
4-
import TextCodeArea from '../sharedComponents/TextCodeArea';
3+
import { RootState } from './src/client/toolkit-refactor/store';
4+
import TextCodeArea from './src/client/components/main/sharedComponents/TextCodeArea';
55

66
/**
77
* renders entry form for TRPC request
88
*/
99

10-
1110
const TRPCBodyEntryForm = (props: any) => {
1211
const { newRequestBodySet } = props;
1312
const dispatch = useDispatch();

index-csp.html

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Swell</title>
7+
</head>
38

4-
<head>
5-
<meta charset="UTF-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<!-- <link rel="stylesheet" href="./node_modules/chart.js/dist/Chart.min.css" /> -->
8-
<title>Swell</title>
9-
</head>
10-
11-
<body></body>
12-
13-
</html>
9+
<body></body>
10+
</html>

main.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
// ** Entry point for Electron **
3434
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron');
3535

36-
3736
const { autoUpdater } = require('electron-updater');
3837
const {
3938
default: installExtension,
@@ -60,7 +59,7 @@ require('./main_process/main_graphqlController')();
6059
require('./main_process/main_grpcController.js')();
6160
require('./main_process/main_wsController.js')();
6261
require('./main_process/main_mockController.js')();
63-
62+
require('./main_process/main_trpcController.js')();
6463

6564
// require mac touchbar
6665
const { touchBar } = require('./main_process/main_touchbar.js');
@@ -218,8 +217,6 @@ app.on('ready', () => {
218217
}
219218
});
220219

221-
222-
223220
// Quit when all windows are closed.
224221
app.on('window-all-closed', () => {
225222
if (mockServerProcess) {
@@ -427,9 +424,13 @@ ipcMain.on('import-proto', (event) => {
427424
if (err) {
428425
return console.log('import-proto error reading file : ', err);
429426
}
430-
427+
431428
protoParserFunc(importedProto).then((protoObj) => {
432-
mainWindow.webContents.send('proto-info', JSON.stringify(importedProto), JSON.stringify(protoObj));
429+
mainWindow.webContents.send(
430+
'proto-info',
431+
JSON.stringify(importedProto),
432+
JSON.stringify(protoObj)
433+
);
433434
});
434435
});
435436
})
@@ -442,8 +443,11 @@ ipcMain.on('import-proto', (event) => {
442443
// Runs the function and returns the value back to GRPCProtoEntryForm
443444
ipcMain.on('protoParserFunc-request', async (event, data) => {
444445
try {
445-
const result = await protoParserFunc(data)
446-
mainWindow.webContents.send('protoParserFunc-return', JSON.stringify(result));
446+
const result = await protoParserFunc(data);
447+
mainWindow.webContents.send(
448+
'protoParserFunc-return',
449+
JSON.stringify(result)
450+
);
447451
} catch (err) {
448452
console.log('error in protoParserFunc-request:, ', err);
449453
mainWindow.webContents.send('protoParserFunc-return', { error: err });
@@ -464,28 +468,30 @@ ipcMain.on('import-openapi', (event) => {
464468
.then((filePaths) => {
465469
if (!filePaths) return undefined;
466470
// read uploaded document & save in the redux store
467-
fs.readFile(filePaths.filePaths[0], 'utf-8', async (err, importedFile) => {
468-
// handle read error
469-
if (err) {
470-
return console.log('import-openapi error reading file : ', err);
471-
}
472-
473-
try {
474-
const documentObj = await openapiParserFunc(importedFile);
475-
// console.log('Main.js - Working here!',documentObj);
476-
mainWindow.webContents.send('openapi-info', documentObj);
477-
} catch (err) {
478-
return console.log('import-openapi error reading file : ', err);
471+
fs.readFile(
472+
filePaths.filePaths[0],
473+
'utf-8',
474+
async (err, importedFile) => {
475+
// handle read error
476+
if (err) {
477+
return console.log('import-openapi error reading file : ', err);
478+
}
479+
480+
try {
481+
const documentObj = await openapiParserFunc(importedFile);
482+
// console.log('Main.js - Working here!',documentObj);
483+
mainWindow.webContents.send('openapi-info', documentObj);
484+
} catch (err) {
485+
return console.log('import-openapi error reading file : ', err);
486+
}
479487
}
480-
481-
});
488+
);
482489
})
483490
.catch((err) => {
484491
console.log('error in import-openapi', err);
485492
});
486493
});
487494

488-
489495
/////////////////////////////////////////////////////////////////////////////////
490496
/////////////////////////////// MOCK SERVER //////////////////////////////////////
491497
/////////////////////////////////////////////////////////////////////////////////

main_process/main_httpController.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ const httpController = {
191191
reqResObj.connectionType = 'plain';
192192
}
193193

194-
// FIXME: There is something wrong with the logic below.
195-
// First, it is checking if the headers have a 'content-length'
196-
// or 'Content-Length' property. If it does not, it sets the
197-
// responseSize to null. It it does, it checks if the headers have
198-
// a 'content-length' property. If it does, it sets the contentLength
199-
// to 'content-length' or 'Content-Length'. This does not make sense.
200-
// I think it should be setting contentLength to headers['content-length']
194+
// FIXME: There is something wrong with the logic below.
195+
// First, it is checking if the headers have a 'content-length'
196+
// or 'Content-Length' property. If it does not, it sets the
197+
// responseSize to null. It it does, it checks if the headers have
198+
// a 'content-length' property. If it does, it sets the contentLength
199+
// to 'content-length' or 'Content-Length'. This does not make sense.
200+
// I think it should be setting contentLength to headers['content-length']
201201
// or headers['Content-Length'].
202202

203203
// check if response comes with 'content-length' header
@@ -209,14 +209,14 @@ const httpController = {
209209
? (contentLength = 'content-length')
210210
: (contentLength = 'Content-Length');
211211

212-
// FIXME: A previous group used a conversion figure of 1023.89427 to
213-
// convert octets to bytes. This is incorrect because both an octet
214-
// and byte are exactly 8 bits in modern computing. There could, however,
215-
// be some ambiguity because "bytes" may have a different meaning in legacy
216-
// systems. Check out this link for more info: https://en.wikipedia.org/wiki/Octet_(computing).
217-
// If the desired responseSize is in bytes, it is enough to simply assign the value
212+
// FIXME: A previous group used a conversion figure of 1023.89427 to
213+
// convert octets to bytes. This is incorrect because both an octet
214+
// and byte are exactly 8 bits in modern computing. There could, however,
215+
// be some ambiguity because "bytes" may have a different meaning in legacy
216+
// systems. Check out this link for more info: https://en.wikipedia.org/wiki/Octet_(computing).
217+
// If the desired responseSize is in bytes, it is enough to simply assign the value
218218
// of the content-length header.
219-
219+
220220
// Converting content length octets into bytes
221221
const conversionFigure = 1023.89427;
222222
const octetToByteConversion =
@@ -295,7 +295,6 @@ const httpController = {
295295
const { method, headers, body } = args.options;
296296
const response = await fetch(headers.url, { method, headers, body });
297297
const headersResponse = response.headers.raw();
298-
299298
if (headersResponse['content-type'][0].includes('stream')) {
300299
return {
301300
headers: headersResponse,
@@ -334,7 +333,6 @@ const httpController = {
334333
reqResObj.timeSent = Date.now();
335334

336335
const options = this.parseFetchOptionsFromReqRes(reqResObj);
337-
338336
//-----------------------------------------
339337
// Check if the URL provided is a stream
340338
//-----------------------------------------
@@ -404,7 +402,7 @@ const httpController = {
404402
cookies.forEach((cookie) => {
405403
const cookieString = `${cookie.key}=${cookie.value}`;
406404
// attach to formattedHeaders so options object includes this
407-
formattedHeaders.cookie = cookieString;
405+
formattedHeaders.cookie = formattedHeaders.cookie + ';' + cookieString;
408406
});
409407
}
410408

0 commit comments

Comments
 (0)