Comparing version 0.0.2 to 0.0.3
@@ -22,5 +22,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
export declare const urlencodedBodyContext: { | ||
readonly value: { | ||
[x: string]: any; | ||
} | undefined; | ||
readonly value: import("qs").ParsedQs | undefined; | ||
chain(params_0?: { | ||
@@ -27,0 +25,0 @@ simplify?: boolean | undefined; |
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { Writable } from 'node:stream'; | ||
export declare const expressContext: { | ||
readonly value: { | ||
charset?: BufferEncoding | undefined; | ||
beautify?: boolean | undefined; | ||
jsonBeautify?: boolean | undefined; | ||
disableEtag?: boolean | undefined; | ||
} & ({ | ||
@@ -21,5 +24,9 @@ type: 'text'; | ||
data: string; | ||
} | { | ||
type: 'stream'; | ||
data: Writable; | ||
}); | ||
chain(params_0?: { | ||
jsonBeautify?: boolean | undefined; | ||
disableEtag?: boolean | undefined; | ||
} | undefined): <V>(next: () => V) => Promise<any>; | ||
@@ -36,2 +43,5 @@ }; | ||
}): void; | ||
export declare function setStream(stream: Writable, { status }?: { | ||
status?: number; | ||
}): void; | ||
export declare function setJson(json: any, { status, beautify }?: { | ||
@@ -38,0 +48,0 @@ status?: number; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setRedirect = exports.setJson = exports.setBuffer = exports.setHtml = exports.setText = exports.expressContext = void 0; | ||
exports.setRedirect = exports.setJson = exports.setStream = exports.setBuffer = exports.setHtml = exports.setText = exports.expressContext = void 0; | ||
const jdefer_1 = __importDefault(require("jdefer")); | ||
@@ -12,7 +12,8 @@ const node_util_1 = require("node:util"); | ||
const context_js_1 = require("./context.js"); | ||
exports.expressContext = (0, context_js_1.makeContext)(async ({ jsonBeautify } = {}) => { | ||
exports.expressContext = (0, context_js_1.makeContext)(async ({ jsonBeautify, disableEtag } = {}) => { | ||
return { | ||
beautify: jsonBeautify, | ||
jsonBeautify, | ||
disableEtag, | ||
}; | ||
}, async (ret, { type, data, charset, beautify }) => { | ||
}, async (ret, { type, data, charset, jsonBeautify, disableEtag }) => { | ||
const res = context_js_1.responseContext.value; | ||
@@ -37,5 +38,9 @@ const setContentType = (contentType) => { | ||
break; | ||
case 'stream': | ||
setContentType('application/octet-stream'); | ||
buffer = data; | ||
break; | ||
case 'json': | ||
setContentType('application/json'); | ||
buffer = Buffer.from(beautify ? JSON.stringify(data, null, 2) : JSON.stringify(data), charset); | ||
buffer = Buffer.from(jsonBeautify ? JSON.stringify(data, null, 2) : JSON.stringify(data), charset); | ||
break; | ||
@@ -84,16 +89,25 @@ case 'redirect': | ||
else { | ||
// support: 304 (etag), zipping, file etag and last modified | ||
res.setHeader('content-length', buffer.length); | ||
const etag = (0, etag_js_1.entityTag)(buffer); | ||
const lastModified = res.getHeader('last-modified'); | ||
res.setHeader('ETag', etag); | ||
if ((0, etag_js_1.isFreshETag)(req, etag)) { | ||
res.removeHeader('content-type'); | ||
res.removeHeader('content-length'); | ||
res.removeHeader('transfer-encoding'); | ||
res.statusCode = 304; | ||
// write nothing | ||
if (Buffer.isBuffer(buffer)) { | ||
// support: 304 (etag), zipping, file etag and last modified | ||
res.setHeader('content-length', buffer.length); | ||
if (!disableEtag) { | ||
const etag = (0, etag_js_1.entityTag)(buffer); | ||
const lastModified = res.getHeader('last-modified'); | ||
res.setHeader('ETag', etag); | ||
if ((0, etag_js_1.isFreshETag)(req, etag)) { | ||
res.removeHeader('content-type'); | ||
res.removeHeader('content-length'); | ||
res.removeHeader('transfer-encoding'); | ||
res.statusCode = 304; | ||
// write nothing | ||
} | ||
else | ||
res.write(buffer); | ||
} | ||
else | ||
res.write(buffer); | ||
} | ||
else | ||
res.write(buffer); | ||
else { | ||
buffer.pipe(res); | ||
} | ||
// fixme: not support content-encoding (gzip, deflate, br) for now | ||
@@ -105,2 +119,3 @@ } | ||
}); | ||
// todo: support setFile (with stream or with buffer) | ||
function setText(text, { status } = {}) { | ||
@@ -130,2 +145,11 @@ const response = context_js_1.responseContext.value; | ||
exports.setBuffer = setBuffer; | ||
function setStream(stream, { status } = {}) { | ||
const response = context_js_1.responseContext.value; | ||
const express = exports.expressContext.value; | ||
if (status) | ||
response.statusCode = status; | ||
express.data = stream; | ||
express.type = 'stream'; | ||
} | ||
exports.setStream = setStream; | ||
function setJson(json, { status, beautify } = {}) { | ||
@@ -139,3 +163,3 @@ const response = context_js_1.responseContext.value; | ||
if (beautify !== undefined) | ||
express.beautify = beautify; | ||
express.jsonBeautify = beautify; | ||
} | ||
@@ -151,2 +175,2 @@ exports.setJson = setJson; | ||
exports.setRedirect = setRedirect; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwcmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9leHByZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLG9EQUE4QjtBQUM5Qix5Q0FBbUM7QUFDbkMsdUNBQWdEO0FBQ2hELDZDQUF5RTtBQUU1RCxRQUFBLGNBQWMsR0FBRyxJQUFBLHdCQUFXLEVBQUMsS0FBSyxFQUM5QyxFQUFDLFlBQVksS0FFVCxFQUFFLEVBQ0wsRUFBRTtJQUNILE9BQU87UUFDTixRQUFRLEVBQUUsWUFBWTtLQTBCckIsQ0FBQTtBQUNILENBQUMsRUFBRSxLQUFLLEVBQUUsR0FBRyxFQUFFLEVBQUMsSUFBSSxFQUFFLElBQUksRUFBRSxPQUFPLEVBQUUsUUFBUSxFQUFDLEVBQUUsRUFBRTtJQUNqRCxNQUFNLEdBQUcsR0FBRyw0QkFBZSxDQUFDLEtBQUssQ0FBQTtJQUNqQyxNQUFNLGNBQWMsR0FBRyxDQUFDLFdBQW1CLEVBQUUsRUFBRTtRQUM5QyxJQUFJLEdBQUcsQ0FBQyxXQUFXLElBQUksR0FBRyxDQUFDLFNBQVMsQ0FBQyxjQUFjLENBQUM7WUFBR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QUFRLENBQUE7QUFDNUQsQ0FBQztBQVhELDBCQVdDO0FBRUQsU0FBZ0IsV0FBVyxDQUFDLEdBQVcsRUFBRSxNQUFpQjtJQUN6RCxNQUFNLFFBQVEsR0FBRyw0QkFBZSxDQUFDLEtBQUssQ0FBQTtJQUN0QyxNQUFNLE9BQU8sR0FBRyxzQkFBYyxDQUFDLEtBQUssQ0FBQTtJQUNwQyxRQUFRLENBQUMsVUFBVSxHQUFHLE1BQU0sQ0FBQTtJQUM1QixPQUFPLENBQUMsSUFBSSxHQUFHLEdBQUcsQ0FBQTtJQUNsQixPQUFPLENBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQTtBQUMxQixDQUFDO0FBTkQsa0NBTUMifQ== |
@@ -22,5 +22,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
export declare const urlencodedBodyContext: { | ||
readonly value: { | ||
[x: string]: any; | ||
} | undefined; | ||
readonly value: import("qs").ParsedQs | undefined; | ||
chain(params_0?: { | ||
@@ -27,0 +25,0 @@ simplify?: boolean | undefined; |
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { Writable } from 'node:stream'; | ||
export declare const expressContext: { | ||
readonly value: { | ||
charset?: BufferEncoding | undefined; | ||
beautify?: boolean | undefined; | ||
jsonBeautify?: boolean | undefined; | ||
disableEtag?: boolean | undefined; | ||
} & ({ | ||
@@ -21,5 +24,9 @@ type: 'text'; | ||
data: string; | ||
} | { | ||
type: 'stream'; | ||
data: Writable; | ||
}); | ||
chain(params_0?: { | ||
jsonBeautify?: boolean | undefined; | ||
disableEtag?: boolean | undefined; | ||
} | undefined): <V>(next: () => V) => Promise<any>; | ||
@@ -36,2 +43,5 @@ }; | ||
}): void; | ||
export declare function setStream(stream: Writable, { status }?: { | ||
status?: number; | ||
}): void; | ||
export declare function setJson(json: any, { status, beautify }?: { | ||
@@ -38,0 +48,0 @@ status?: number; |
@@ -5,7 +5,8 @@ import makeDefer from 'jdefer'; | ||
import { makeContext, requestContext, responseContext } from './context.js'; | ||
export const expressContext = makeContext(async ({ jsonBeautify } = {}) => { | ||
export const expressContext = makeContext(async ({ jsonBeautify, disableEtag } = {}) => { | ||
return { | ||
beautify: jsonBeautify, | ||
jsonBeautify, | ||
disableEtag, | ||
}; | ||
}, async (ret, { type, data, charset, beautify }) => { | ||
}, async (ret, { type, data, charset, jsonBeautify, disableEtag }) => { | ||
const res = responseContext.value; | ||
@@ -30,5 +31,9 @@ const setContentType = (contentType) => { | ||
break; | ||
case 'stream': | ||
setContentType('application/octet-stream'); | ||
buffer = data; | ||
break; | ||
case 'json': | ||
setContentType('application/json'); | ||
buffer = Buffer.from(beautify ? JSON.stringify(data, null, 2) : JSON.stringify(data), charset); | ||
buffer = Buffer.from(jsonBeautify ? JSON.stringify(data, null, 2) : JSON.stringify(data), charset); | ||
break; | ||
@@ -77,16 +82,25 @@ case 'redirect': | ||
else { | ||
// support: 304 (etag), zipping, file etag and last modified | ||
res.setHeader('content-length', buffer.length); | ||
const etag = entityTag(buffer); | ||
const lastModified = res.getHeader('last-modified'); | ||
res.setHeader('ETag', etag); | ||
if (isFreshETag(req, etag)) { | ||
res.removeHeader('content-type'); | ||
res.removeHeader('content-length'); | ||
res.removeHeader('transfer-encoding'); | ||
res.statusCode = 304; | ||
// write nothing | ||
if (Buffer.isBuffer(buffer)) { | ||
// support: 304 (etag), zipping, file etag and last modified | ||
res.setHeader('content-length', buffer.length); | ||
if (!disableEtag) { | ||
const etag = entityTag(buffer); | ||
const lastModified = res.getHeader('last-modified'); | ||
res.setHeader('ETag', etag); | ||
if (isFreshETag(req, etag)) { | ||
res.removeHeader('content-type'); | ||
res.removeHeader('content-length'); | ||
res.removeHeader('transfer-encoding'); | ||
res.statusCode = 304; | ||
// write nothing | ||
} | ||
else | ||
res.write(buffer); | ||
} | ||
else | ||
res.write(buffer); | ||
} | ||
else | ||
res.write(buffer); | ||
else { | ||
buffer.pipe(res); | ||
} | ||
// fixme: not support content-encoding (gzip, deflate, br) for now | ||
@@ -98,2 +112,3 @@ } | ||
}); | ||
// todo: support setFile (with stream or with buffer) | ||
export function setText(text, { status } = {}) { | ||
@@ -120,2 +135,10 @@ const response = responseContext.value; | ||
} | ||
export function setStream(stream, { status } = {}) { | ||
const response = responseContext.value; | ||
const express = expressContext.value; | ||
if (status) | ||
response.statusCode = status; | ||
express.data = stream; | ||
express.type = 'stream'; | ||
} | ||
export function setJson(json, { status, beautify } = {}) { | ||
@@ -129,3 +152,3 @@ const response = responseContext.value; | ||
if (beautify !== undefined) | ||
express.beautify = beautify; | ||
express.jsonBeautify = beautify; | ||
} | ||
@@ -139,2 +162,2 @@ export function setRedirect(url, status) { | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwcmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9leHByZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sU0FBUyxNQUFNLFFBQVEsQ0FBQTtBQUM5QixPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sV0FBVyxDQUFBO0FBQ25DLE9BQU8sRUFBQyxTQUFTLEVBQUUsV0FBVyxFQUFDLE1BQU0sV0FBVyxDQUFBO0FBQ2hELE9BQU8sRUFBQyxXQUFXLEVBQUUsY0FBYyxFQUFFLGVBQWUsRUFBQyxNQUFNLGNBQWMsQ0FBQTtBQUV6RSxNQUFNLENBQUMsTUFBTSxjQUFjLEdBQUcsV0FBVyxDQUFDLEtBQUssRUFDOUMsRUFBQyxZQUFZLEtBRVQsRUFBRSxFQUNMLEVBQUU7SUFDSCxPQUFPO1FBQ04sUUFBUSxFQUFFLFlBQVk7S0EwQnJCLENBQUE7QUFDSCxDQUFDLEVBQUUsS0FBSyxFQUFFLEdBQUcsRUFBRSxFQUFDLElBQUksRUFBRSxJQUFJLEVBQUUsT0FBTyxFQUFFLFFBQVEsRUFBQy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QU0sQ0FBQTtJQUV4QyxNQUFNLE9BQU8sR0FBRyxjQUFjLENBQUMsS0FBSyxDQUFBO0lBQ3BDLE9BQU8sQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFBO0lBQ25CLE9BQU8sQ0FBQyxJQUFJLEdBQUcsTUFBTSxDQUFBO0lBQ3JCLElBQUksUUFBUSxLQUFLLFNBQVM7UUFBRSxPQUFPLENBQUMsWUFBWSxHQUFHLFFBQVEsQ0FBQTtBQUM1RCxDQUFDO0FBRUQsTUFBTSxVQUFVLFdBQVcsQ0FBQyxHQUFXLEVBQUUsTUFBaUI7SUFDekQsTUFBTSxRQUFRLEdBQUcsZUFBZSxDQUFDLEtBQUssQ0FBQTtJQUN0QyxNQUFNLE9BQU8sR0FBRyxjQUFjLENBQUMsS0FBSyxDQUFBO0lBQ3BDLFFBQVEsQ0FBQyxVQUFVLEdBQUcsTUFBTSxDQUFBO0lBQzVCLE9BQU8sQ0FBQyxJQUFJLEdBQUcsR0FBRyxDQUFBO0lBQ2xCLE9BQU8sQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFBO0FBQzFCLENBQUMifQ== |
{ | ||
"name": "dx-server", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "./cjs/index.js", | ||
"repository": "git@github.com:tranvansang/dx-server.git", | ||
"repository": "https://github.com/tranvansang/dx-server", | ||
"author": "Sang Tran <t@sang.jp>", | ||
@@ -32,3 +32,3 @@ "files": [ | ||
"jdefer": "^0.0.9", | ||
"jmisc": "^0.0.8", | ||
"jmisc": "^0.0.9", | ||
"path-to-regexp": "^6.2.1", | ||
@@ -35,0 +35,0 @@ "qs": "^6.11.2" |
@@ -72,3 +72,3 @@ # dx-server - modern, unopinionated, and satisfactory server | ||
// req, res can be accessed from anywhere via context which uses NodeJS's AsyncLocalStorage under the hood | ||
responseContext.value.setHeader('cache-control', 'no-cache') | ||
responseContext.value.setHeader('Cache-Control', 'no-cache') | ||
next() | ||
@@ -75,0 +75,0 @@ }, |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
149472
1936
0
+ Addedjmisc@0.0.9(transitive)
- Removedjmisc@0.0.8(transitive)
Updatedjmisc@^0.0.9