@tinyhttp/res
Advanced tools
Comparing version 0.1.10 to 0.1.12
# @tinyhttp/res | ||
## 0.1.12 | ||
### Patch Changes | ||
- Updated dependencies [undefined] | ||
- @tinyhttp/req@0.1.8 | ||
## 0.1.11 | ||
### Patch Changes | ||
- Add res.type() | ||
## 0.1.10 | ||
@@ -4,0 +17,0 @@ |
@@ -6,5 +6,6 @@ /// <reference types="node" /> | ||
export declare const getResponseHeader: <Request_1 extends I = I, Response_1 extends S = S>(_req: Request_1, res: Response_1) => (field: string) => string | number | string[]; | ||
export declare const setLinksHeader: <Request_1 extends I = I, Response_1 extends S = S>(_req: Request_1, res: Response_1) => (links: { | ||
export declare const setLinksHeader: <Request_1 extends I = I, Response_1 extends S = S>(req: Request_1, res: Response_1) => (links: { | ||
[key: string]: string; | ||
}) => Response_1; | ||
export declare const setVaryHeader: <Request_1 extends I = I, Response_1 extends S = S>(_req: Request_1, res: Response_1) => (field: string) => Response_1; | ||
export declare const setContentType: <Request_1 extends I = I, Response_1 extends S = S>(req: Request_1, res: Response_1) => (type: string) => Response_1; |
@@ -72,7 +72,7 @@ export * from '@tinyhttp/send'; | ||
}; | ||
const setLinksHeader = (_req, res) => (links) => { | ||
const setLinksHeader = (req, res) => (links) => { | ||
let link = res.getHeader('Link') || ''; | ||
if (link) | ||
link += ', '; | ||
res.setHeader('Link', link + | ||
setHeader(req, res)('Link', link + | ||
Object.keys(links) | ||
@@ -87,2 +87,6 @@ .map((rel) => '<' + links[rel] + '>; rel="' + rel + '"') | ||
}; | ||
const setContentType = (req, res) => (type) => { | ||
const ct = type.indexOf('/') === -1 ? lookup(type) : type; | ||
return setHeader(req, res)('Content-Type', ct); | ||
}; | ||
@@ -166,2 +170,2 @@ const normalizeType = (type) => { | ||
export { clearCookie, formatResponse, getResponseHeader, redirect, setCookie, setHeader, setLinksHeader, setLocationHeader, setVaryHeader }; | ||
export { clearCookie, formatResponse, getResponseHeader, redirect, setContentType, setCookie, setHeader, setLinksHeader, setLocationHeader, setVaryHeader }; |
{ | ||
"name": "@tinyhttp/res", | ||
"version": "0.1.10", | ||
"version": "0.1.12", | ||
"type": "module", | ||
@@ -42,3 +42,3 @@ "description": "response extensions for tinyhttp", | ||
"@tinyhttp/cookie-signature": "0.2.2", | ||
"@tinyhttp/req": "^0.1.7", | ||
"@tinyhttp/req": "^0.1.8", | ||
"@tinyhttp/send": "0.1.3", | ||
@@ -45,0 +45,0 @@ "es-mime-types": "^0.0.16", |
@@ -11,3 +11,3 @@ import { IncomingMessage as I, ServerResponse as S } from 'http' | ||
val?: string | any[] | ||
) => { | ||
): Response => { | ||
if (typeof field === 'string') { | ||
@@ -53,6 +53,6 @@ let value = Array.isArray(val) ? val.map(String) : String(val) | ||
export const setLinksHeader = <Request extends I = I, Response extends S = S>(_req: Request, res: Response) => (links: { [key: string]: string }): Response => { | ||
export const setLinksHeader = <Request extends I = I, Response extends S = S>(req: Request, res: Response) => (links: { [key: string]: string }): Response => { | ||
let link = res.getHeader('Link') || '' | ||
if (link) link += ', ' | ||
res.setHeader( | ||
setHeader(req, res)( | ||
'Link', | ||
@@ -68,3 +68,3 @@ link + | ||
export const setVaryHeader = <Request extends I = I, Response extends S = S>(_req: Request, res: Response) => (field: string) => { | ||
export const setVaryHeader = <Request extends I = I, Response extends S = S>(_req: Request, res: Response) => (field: string): Response => { | ||
vary(res, field) | ||
@@ -74,1 +74,7 @@ | ||
} | ||
export const setContentType = <Request extends I = I, Response extends S = S>(req: Request, res: Response) => (type: string): Response => { | ||
const ct = type.indexOf('/') === -1 ? mime.lookup(type) : type | ||
return setHeader(req, res)('Content-Type', ct) | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27252
598
Updated@tinyhttp/req@^0.1.8