insomnia/packages/insomnia-app/app/main/curl-ipc-main.ts
Jack Kavanagh 80e5161a20
Fix: disabled native modules in the renderer (#4230)
* fix non-context-aware imports

* extract _actuallySend to file

* extract CLI unit test function from renderer

* expose curl functions to the ipc renderer

* use curl through ipcRenderer

* feedback first pass make like grpc

* feedback second pass remove duplicate

* fix lint
2021-12-02 09:26:08 +00:00

19 lines
825 B
TypeScript

import { ipcMain } from 'electron';
import { CurlRequestEvent } from '../common/ipc-events';
import type { RenderedRequest } from '../common/render';
import type { Environment } from '../models/environment';
import type { Workspace } from '../models/workspace';
import { _actuallySend, cancelRequestById } from '../network/curl';
import type { ResponsePatch } from '../network/network';
export function init() {
ipcMain.handle(CurlRequestEvent.send, async (_, renderedRequest: RenderedRequest, workspace: Workspace, settings, environment: Environment | null, validateSSL: boolean): Promise<ResponsePatch> => {
return _actuallySend(renderedRequest, workspace, settings, environment, validateSSL);
});
ipcMain.on(CurlRequestEvent.cancel, (_, requestId: string): void => {
cancelRequestById(requestId);
});
}