New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fastify-auto-push

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-auto-push - npm Package Compare versions

Comparing version

to
0.3.2

3

build/src/index.d.ts
/// <reference types="node" />
/// <reference types="fastify" />
import * as fastify from 'fastify';

@@ -16,2 +17,2 @@ import * as autoPush from 'h2-auto-push';

}
export declare const staticServe: fastify.Plugin<HttpServer, RawRequest, RawResponse, AutoPushOptions>;
export declare const staticServe: fastify.Plugin<HttpServer, http.IncomingMessage | http2.Http2ServerRequest, http.ServerResponse | http2.Http2ServerResponse, AutoPushOptions>;

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

const CACHE_COOKIE_KEY = '__ap_cache__';
const REQ_PATH = Symbol('reqPath');
async function staticServeFn(app, opts) {
const root = opts.root;
const prefix = opts.prefix || '/';
const ap = new autoPush.AutoPush(root, opts.cacheConfig);

@@ -45,5 +45,4 @@ app.register(fastify_static_1.default, opts);

if (isHttp2Request(req)) {
const reqPath = req.url;
const reqStream = req.stream;
const reqPath = req.url;
reqStream[REQ_PATH] = reqPath;
const cookies = cookie.parse(req.headers['cookie'] || '');

@@ -60,9 +59,12 @@ const cacheKey = cookies[CACHE_COOKIE_KEY];

if (isHttp2Response(res)) {
const statusCode = res.statusCode;
const resStream = res.stream;
const statusCode = res.statusCode;
if (statusCode === 404) {
ap.recordRequestPath(resStream.session, resStream[REQ_PATH] || '', false);
const reqPath = request.req.url;
if (statusCode === 404 && reqPath) {
ap.recordRequestPath(resStream.session, reqPath, false);
}
else if (statusCode < 300 && statusCode >= 200) {
ap.recordRequestPath(resStream.session, resStream[REQ_PATH] || '', true);
else if (statusCode < 300 && statusCode >= 200 && reqPath &&
// Record as a static file only when the path starts with `prefix`.
reqPath.startsWith(prefix)) {
ap.recordRequestPath(resStream.session, reqPath, true);
}

@@ -69,0 +71,0 @@ }

{
"name": "fastify-auto-push",
"version": "0.3.1",
"version": "0.3.2",
"description": "HTTP/2 auto-push middleware for fastify",

@@ -50,5 +50,5 @@ "main": "build/src/index.js",

"cookie": "^0.3.1",
"fastify-plugin": "^0.2.2",
"fastify-static": "^0.8.0",
"h2-auto-push": "^0.3.0"
"fastify-plugin": "^1.0.0",
"fastify-static": "^0.10.1",
"h2-auto-push": "^0.3.1"
},

@@ -62,6 +62,6 @@ "devDependencies": {

"codecov": "^3.0.0",
"fastify": "^0.43.0",
"fastify": "^1.0.0",
"get-port": "^3.2.0",
"gts": "^0.5.3",
"js-green-licenses": "^0.4.0",
"js-green-licenses": "^0.5.0",
"nyc": "^11.5.0",

@@ -68,0 +68,0 @@ "typescript": "^2.7.2"

Sorry, the diff of this file is not supported yet