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

@qpoint/router

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qpoint/router - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

9

lib/context.d.ts
/// <reference types="@cloudflare/workers-types" />
export declare class Context {
export declare class Context<Env> {
request: Request;
env: Env;
ctx: ExecutionContext;
state: Object;
event: FetchEvent;
request: Request;
requestId: string;

@@ -12,4 +13,4 @@ url: string;

htmlRewriter: HTMLRewriter;
constructor(event: FetchEvent, state?: Object);
constructor(request: Request, env: Env, ctx: ExecutionContext, state?: Object);
waitUntil(fn: Promise<any>): void;
}

@@ -18,5 +18,6 @@ "use strict";

class Context {
request; // the initial request (read-only)
env; // the custom worker env & bindings
ctx; // execution context of the event
state; // generic object for sharing data between adapters
event; // the worker runtime fetch event
request; // the initial request (read-only)
requestId; // a unique id for this request

@@ -28,13 +29,15 @@ url; // the URL object from the initial request

htmlRewriter; // a rewriter instance for modifying html as a stream
constructor(event, state = {}) {
constructor(request, env, ctx, state = {}) {
// set the request from the event
this.request = request;
// set the env from the event
this.env = env;
// set the execution context of the runtime
this.ctx = ctx;
// allow the router init to set the initial state
this.state = state;
// set the event from the worker event
this.event = event;
// set the request from the event
this.request = event.request;
// create a random request ID
this.requestId = generateId(24);
// set the url initially to that of the request
this.url = event.request.url;
this.url = request.url;
// create a copy of the initial request, which will presumably be modified heavily

@@ -51,3 +54,3 @@ this.proxy = new Request(this.request);

waitUntil(fn) {
this.event.waitUntil(fn);
this.ctx.waitUntil(fn);
}

@@ -54,0 +57,0 @@ }

@@ -7,4 +7,3 @@ /// <reference types="@cloudflare/workers-types" />

use(fn: Function): this;
fetch(event: FetchEvent): Promise<Response>;
listen(): void;
fetch<Env>(request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
}

@@ -27,5 +27,5 @@ "use strict";

// Respond to the fetch event
async fetch(event) {
async fetch(request, env, ctx) {
// initialize a context
const context = new context_1.Context(event, this.state);
const context = new context_1.Context(request, env, ctx, this.state);
// compose the request middlewares

@@ -38,10 +38,4 @@ const run = (0, koa_compose_1.default)(this.stack);

}
// Legacy, this pattern has been deprecated. Expose fetch directly instead
listen() {
addEventListener("fetch", event => {
event.respondWith(this.fetch(event));
});
}
}
exports.Router = Router;
//# sourceMappingURL=router.js.map
{
"name": "@qpoint/router",
"version": "0.1.2",
"version": "0.1.3",
"description": "Qpoint - an intelligent edge router framework",

@@ -5,0 +5,0 @@ "author": "Tyler Flint <tyler@qpoint.io>",

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