Socket
Socket
Sign inDemoInstall

@tinyhttp/req

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/req - npm Package Compare versions

Comparing version 0.5.3 to 0.5.5

14

CHANGELOG.md
# @tinyhttp/req
## 0.5.5
### Patch Changes
- make types more flexible
- Updated dependencies [undefined]
- @tinyhttp/accepts@0.5.2
## 0.5.4
### Patch Changes
- Make types more flexible
## 0.5.3

@@ -4,0 +18,0 @@

5

dist/accepts.d.ts

@@ -1,2 +0,4 @@

import { IncomingMessage as Request } from 'http';
/// <reference types="node" />
import { IncomingMessage as I } from 'http';
declare type Request = Pick<I, 'headers'>;
export declare const getAccepts: (req: Request) => (...types: string[]) => string | false | string[];

@@ -6,1 +8,2 @@ export declare const getAcceptsEncodings: (req: Request) => (...encodings: string[]) => string | false | string[];

export declare const getAcceptsLanguages: (req: Request) => (...languages: string[]) => string | false | string[];
export {};

10

dist/index.d.ts

@@ -5,6 +5,6 @@ import { IncomingMessage as Request, ServerResponse as Response } from 'http';

export * from '@tinyhttp/url';
export declare const getRequestHeader: (req: Request) => (header: string) => string | string[];
export declare const getRangeFromHeader: (req: Request) => (size: number, options?: Options) => -1 | -2 | parseRange.Ranges;
export declare const getFreshOrStale: (req: Request, res: Response) => boolean;
export declare const checkIfXMLHttpRequest: (req: Request) => boolean;
export declare const reqIs: (req: Request) => (...types: string[]) => boolean;
export declare const getRequestHeader: (req: Pick<Request, 'headers'>) => (header: string) => string | string[];
export declare const getRangeFromHeader: (req: Pick<Request, 'headers'>) => (size: number, options?: Options) => -1 | -2 | parseRange.Ranges;
export declare const getFreshOrStale: (req: Pick<Request, 'headers' | 'method'>, res: Pick<Response, 'getHeader' | 'statusCode'>) => boolean;
export declare const checkIfXMLHttpRequest: (req: Pick<Request, 'headers'>) => boolean;
export declare const reqIs: (req: Pick<Request, 'headers'>) => (...types: string[]) => boolean;

@@ -44,9 +44,5 @@ import parseRange from 'range-parser';

};
const checkIfXMLHttpRequest = (req) => {
return req.headers['X-Requested-With'] === 'XMLHttpRequest';
};
const reqIs = (req) => (...types) => {
return typeIs(req.headers['content-type'], ...types);
};
const checkIfXMLHttpRequest = (req) => req.headers['X-Requested-With'] === 'XMLHttpRequest';
const reqIs = (req) => (...types) => typeIs(req.headers['content-type'], ...types);
export { checkIfXMLHttpRequest, getAccepts, getAcceptsCharsets, getAcceptsEncodings, getAcceptsLanguages, getFreshOrStale, getRangeFromHeader, getRequestHeader, reqIs };
{
"name": "@tinyhttp/req",
"version": "0.5.3",
"version": "0.5.5",
"type": "module",

@@ -41,3 +41,3 @@ "description": "request extensions for tinyhttp",

"dependencies": {
"@tinyhttp/accepts": "0.5.1",
"@tinyhttp/accepts": "0.5.2",
"@tinyhttp/type-is": "0.5.2",

@@ -44,0 +44,0 @@ "@tinyhttp/url": "0.5.2",

@@ -1,4 +0,6 @@

import { IncomingMessage as Request, ServerResponse as Response } from 'http'
import { IncomingMessage as I, ServerResponse as Response } from 'http'
import { Accepts } from '@tinyhttp/accepts'
type Request = Pick<I, 'headers'>
export const getAccepts = (req: Request) => (...types: string[]) => new Accepts(req).types(types)

@@ -5,0 +7,0 @@

@@ -10,3 +10,3 @@ import { IncomingMessage as Request, ServerResponse as Response } from 'http'

export const getRequestHeader = (req: Request) => (header: string): string | string[] => {
export const getRequestHeader = (req: Pick<Request, 'headers'>) => (header: string): string | string[] => {
const lc = header.toLowerCase()

@@ -23,3 +23,3 @@

export const getRangeFromHeader = (req: Request) => (size: number, options?: Options) => {
export const getRangeFromHeader = (req: Pick<Request, 'headers'>) => (size: number, options?: Options) => {
const range = getRequestHeader(req)('Range') as string

@@ -32,3 +32,3 @@

export const getFreshOrStale = (req: Request, res: Response) => {
export const getFreshOrStale = (req: Pick<Request, 'headers' | 'method'>, res: Pick<Response, 'getHeader' | 'statusCode'>) => {
const method = req.method

@@ -53,8 +53,4 @@ const status = res.statusCode

export const checkIfXMLHttpRequest = (req: Request): boolean => {
return req.headers['X-Requested-With'] === 'XMLHttpRequest'
}
export const checkIfXMLHttpRequest = (req: Pick<Request, 'headers'>) => req.headers['X-Requested-With'] === 'XMLHttpRequest'
export const reqIs = (req: Request) => (...types: string[]): boolean => {
return typeIs(req.headers['content-type'], ...types)
}
export const reqIs = (req: Pick<Request, 'headers'>) => (...types: string[]): boolean => typeIs(req.headers['content-type'], ...types)

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