Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@composite-fetcher/core

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@composite-fetcher/core - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

15

./dist/index.js

@@ -37,3 +37,3 @@ // src/interfaces/index.ts

const isPostRequestContext = this.isPostRequestContext(context);
const next = () => {
const next = async () => {
if (index >= this.plugins.length) {

@@ -64,6 +64,13 @@ if (isPreRequestContext) {

};
Promise.resolve(plugin[method]?.(context)).catch((error) => {
const result = await plugin[method]?.(context).catch((error) => {
console.error(`Error in plugin: ${error}`);
clearTimeout(timeout);
context.next();
});
if (result instanceof Response) {
clearTimeout(timeout);
resolve(result);
return;
}
context.next();
};

@@ -124,3 +131,2 @@ next();

}
// test
async fetch(input, init) {

@@ -131,2 +137,5 @@ const originalRequest = new Request(input, init);

);
if (modifiedRequest instanceof Response) {
return modifiedRequest;
}
const response = await fetch(modifiedRequest);

@@ -133,0 +142,0 @@ const modifiedResponse = await this.pluginManager.runPostRequestHooks(

10

dist/index.d.ts

@@ -11,3 +11,3 @@ declare class PluginManager {

private processPlugins;
runPreRequestHooks(request: Request): Promise<Request>;
runPreRequestHooks(request: Request): Promise<Request | Response>;
runPostRequestHooks(response: Response, originalRequest: Request): Promise<Response>;

@@ -38,4 +38,4 @@ getModifiedRequest(): Request;

pluginTimeout?: number;
onPreRequest?: (context: PluginHandlerContext<PluginLifecycleHook.PRE_REQUEST>) => Promise<void>;
onPostRequest?: (context: PluginHandlerContext<PluginLifecycleHook.POST_REQUEST>) => Promise<void>;
onPreRequest?: (context: PluginHandlerContext<PluginLifecycleHook.PRE_REQUEST>) => Promise<void | Response>;
onPostRequest?: (context: PluginHandlerContext<PluginLifecycleHook.POST_REQUEST>) => Promise<void | Response>;
}

@@ -51,6 +51,6 @@

pluginTimeout?: number;
onPreRequest(context: PluginHandlerContext<PluginLifecycleHook.PRE_REQUEST>): Promise<void>;
onPostRequest(context: PluginHandlerContext<PluginLifecycleHook.POST_REQUEST>): Promise<void>;
onPreRequest(context: PluginHandlerContext<PluginLifecycleHook.PRE_REQUEST>): Promise<void | Response>;
onPostRequest(context: PluginHandlerContext<PluginLifecycleHook.POST_REQUEST>): Promise<void | Response>;
}
export { BasePlugin, Fetcher, Plugin, PluginHandlerContext, PluginLifecycleHook, PostRequestPluginHandlerContext, PreRequestPluginHandlerContext };

@@ -37,3 +37,3 @@ // src/interfaces/index.ts

const isPostRequestContext = this.isPostRequestContext(context);
const next = () => {
const next = async () => {
if (index >= this.plugins.length) {

@@ -64,6 +64,13 @@ if (isPreRequestContext) {

};
Promise.resolve(plugin[method]?.(context)).catch((error) => {
const result = await plugin[method]?.(context).catch((error) => {
console.error(`Error in plugin: ${error}`);
clearTimeout(timeout);
context.next();
});
if (result instanceof Response) {
clearTimeout(timeout);
resolve(result);
return;
}
context.next();
};

@@ -124,3 +131,2 @@ next();

}
// test
async fetch(input, init) {

@@ -131,2 +137,5 @@ const originalRequest = new Request(input, init);

);
if (modifiedRequest instanceof Response) {
return modifiedRequest;
}
const response = await fetch(modifiedRequest);

@@ -133,0 +142,0 @@ const modifiedResponse = await this.pluginManager.runPostRequestHooks(

{
"name": "@composite-fetcher/core",
"description": "Fetcher core",
"version": "0.0.3",
"version": "0.1.0",
"author": "Teofanis Papadopulos",

@@ -6,0 +6,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc