added doga
This commit is contained in:
21
25_02_24/node_modules/@tinyhttp/res/LICENSE
generated
vendored
Normal file
21
25_02_24/node_modules/@tinyhttp/res/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 v 1 r t l
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
19
25_02_24/node_modules/@tinyhttp/res/README.md
generated
vendored
Normal file
19
25_02_24/node_modules/@tinyhttp/res/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# @tinyhttp/res
|
||||
|
||||
[![npm (scoped)][npm-badge]](https://npmjs.com/package/@tinyhttp/res) [![npm][dl-badge]](https://npmjs.com/package/@tinyhttp/res) [![][web-badge]](https://tinyhttp.v1rtl.site/mw/res)
|
||||
|
||||
Response extensions for tinyhttp collected in one package. This module itself depends on other modules, such as [`@tinyhttp/send`](/packages/send).
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
pnpm i @tinyhttp/res
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
[tinyhttp Response docs](https://tinyhttp.v1rtl.site/docs#response).
|
||||
|
||||
[npm-badge]: https://img.shields.io/npm/v/@tinyhttp/res?style=flat-square
|
||||
[dl-badge]: https://img.shields.io/npm/dt/@tinyhttp/res?style=flat-square
|
||||
[web-badge]: https://img.shields.io/badge/website-visit-hotpink?style=flat-square
|
||||
3
25_02_24/node_modules/@tinyhttp/res/dist/append.d.ts
generated
vendored
Normal file
3
25_02_24/node_modules/@tinyhttp/res/dist/append.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { ServerResponse as Res } from 'node:http';
|
||||
export declare const append: <Response extends Res = Res<import("http").IncomingMessage>>(res: Response) => (field: string, value: string | number | string[]) => Response;
|
||||
//# sourceMappingURL=append.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/append.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/append.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,GAAG,EAAE,MAAM,WAAW,CAAA;AAGtD,eAAO,MAAM,MAAM,GAChB,QAAQ,SAAS,GAAG,6CAAa,QAAQ,aAClC,MAAM,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,KAAG,QAanD,CAAA"}
|
||||
15
25_02_24/node_modules/@tinyhttp/res/dist/append.js
generated
vendored
Normal file
15
25_02_24/node_modules/@tinyhttp/res/dist/append.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { getResponseHeader, setHeader } from './headers.js';
|
||||
export const append = (res) => (field, value) => {
|
||||
const prevVal = getResponseHeader(res)(field);
|
||||
let newVal = value;
|
||||
if (prevVal && typeof newVal !== 'number' && typeof prevVal !== 'number') {
|
||||
newVal = Array.isArray(prevVal)
|
||||
? prevVal.concat(newVal)
|
||||
: Array.isArray(newVal)
|
||||
? [prevVal].concat(newVal)
|
||||
: [prevVal, newVal];
|
||||
}
|
||||
setHeader(res)(field, newVal);
|
||||
return res;
|
||||
};
|
||||
//# sourceMappingURL=append.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/append.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/append.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"append.js","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE3D,MAAM,CAAC,MAAM,MAAM,GACjB,CAA6B,GAAa,EAAE,EAAE,CAC9C,CAAC,KAAa,EAAE,KAAiC,EAAY,EAAE;IAC7D,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;IAC7C,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB,IAAI,OAAO,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzE,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACxB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBACrB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC1B,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACzB,CAAC;IACD,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC7B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
||||
9
25_02_24/node_modules/@tinyhttp/res/dist/cookie.d.ts
generated
vendored
Normal file
9
25_02_24/node_modules/@tinyhttp/res/dist/cookie.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { IncomingMessage as Req, ServerResponse as Res } from 'node:http';
|
||||
import * as cookie from '@tinyhttp/cookie';
|
||||
export declare const setCookie: <Request extends Req = Req, Response extends Res = Res<Req>>(req: Request & {
|
||||
secret?: string | string[];
|
||||
}, res: Response) => (name: string, value: string | Record<string, unknown>, options?: cookie.SerializeOptions & Partial<{
|
||||
signed: boolean;
|
||||
}>) => Response;
|
||||
export declare const clearCookie: <Request extends Req = Req, Response extends Res = Res<Req>>(req: Request, res: Response) => (name: string, options?: cookie.SerializeOptions) => Response;
|
||||
//# sourceMappingURL=cookie.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/cookie.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/cookie.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../src/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,GAAG,EAAE,cAAc,IAAI,GAAG,EAAE,MAAM,WAAW,CAAA;AAC9E,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAI1C,eAAO,MAAM,SAAS,GACnB,OAAO,SAAS,GAAG,QAAQ,QAAQ,SAAS,GAAG,kBACzC,OAAO,GAAG;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC3B,OACI,QAAQ,YAGP,MAAM,SACL,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAC9B,MAAM,CAAC,gBAAgB,GAC9B,OAAO,CAAC;IACN,MAAM,EAAE,OAAO,CAAA;CAChB,CAAC,KACH,QAqBF,CAAA;AAEH,eAAO,MAAM,WAAW,GACrB,OAAO,SAAS,GAAG,QAAQ,QAAQ,SAAS,GAAG,kBAAa,OAAO,OAAO,QAAQ,YAC5E,MAAM,YAAY,MAAM,CAAC,gBAAgB,KAAG,QAElD,CAAA"}
|
||||
24
25_02_24/node_modules/@tinyhttp/res/dist/cookie.js
generated
vendored
Normal file
24
25_02_24/node_modules/@tinyhttp/res/dist/cookie.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as cookie from '@tinyhttp/cookie';
|
||||
import { sign } from '@tinyhttp/cookie-signature';
|
||||
import { append } from './append.js';
|
||||
export const setCookie = (req, res) => (name, value, options = {}) => {
|
||||
const secret = req.secret;
|
||||
const signed = options.signed || false;
|
||||
if (signed && !secret)
|
||||
throw new Error('cookieParser("secret") required for signed cookies');
|
||||
let val = typeof value === 'object' ? `j:${JSON.stringify(value)}` : String(value);
|
||||
if (signed)
|
||||
val = `s:${sign(val, secret)}`;
|
||||
if (options.maxAge) {
|
||||
options.expires = new Date(Date.now() + options.maxAge);
|
||||
options.maxAge /= 1000;
|
||||
}
|
||||
if (options.path == null)
|
||||
options.path = '/';
|
||||
append(res)('Set-Cookie', `${cookie.serialize(name, String(val), options)}`);
|
||||
return res;
|
||||
};
|
||||
export const clearCookie = (req, res) => (name, options) => {
|
||||
return setCookie(req, res)(name, '', Object.assign({}, { expires: new Date(1), path: '/' }, options));
|
||||
};
|
||||
//# sourceMappingURL=cookie.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/cookie.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/cookie.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cookie.js","sourceRoot":"","sources":["../src/cookie.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,CAAC,MAAM,SAAS,GACpB,CACE,GAEC,EACD,GAAa,EACb,EAAE,CAC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OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC,CAAA;AACvG,CAAC,CAAA"}
|
||||
10
25_02_24/node_modules/@tinyhttp/res/dist/download.d.ts
generated
vendored
Normal file
10
25_02_24/node_modules/@tinyhttp/res/dist/download.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { IncomingMessage as Req, ServerResponse as Res } from 'node:http';
|
||||
import type { SendFileOptions } from '@tinyhttp/send';
|
||||
export type DownloadOptions = SendFileOptions & Partial<{
|
||||
headers: Record<string, string>;
|
||||
}>;
|
||||
type Callback = (err?: any) => void;
|
||||
export declare const download: <Request extends Req = Req, Response extends Res = Res<Req>>(req: Request, res: Response) => (path: string, filename?: string | Callback, options?: DownloadOptions | Callback, cb?: Callback) => Response;
|
||||
export declare const attachment: <Response extends Res>(res: Response) => (filename?: string) => Response;
|
||||
export {};
|
||||
//# sourceMappingURL=download.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/download.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/download.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,GAAG,EAAE,cAAc,IAAI,GAAG,EAAE,MAAM,WAAW,CAAA;AAI9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGrD,MAAM,MAAM,eAAe,GAAG,eAAe,GAC3C,OAAO,CAAC;IACN,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC,CAAC,CAAA;AAEJ,KAAK,QAAQ,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;AAEnC,eAAO,MAAM,QAAQ,GAClB,OAAO,SAAS,GAAG,QAAQ,QAAQ,SAAS,GAAG,kBAAa,OAAO,OAAO,QAAQ,YAC5E,MAAM,aAAa,MAAM,GAAG,QAAQ,YAAY,eAAe,GAAG,QAAQ,OAAO,QAAQ,KAAG,QAgClG,CAAA;AAEH,eAAO,MAAM,UAAU,GACpB,QAAQ,SAAS,GAAG,OAAO,QAAQ,iBACxB,MAAM,KAAG,QASpB,CAAA"}
|
||||
42
25_02_24/node_modules/@tinyhttp/res/dist/download.js
generated
vendored
Normal file
42
25_02_24/node_modules/@tinyhttp/res/dist/download.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { basename, extname, resolve } from 'node:path';
|
||||
import { contentDisposition } from '@tinyhttp/content-disposition';
|
||||
import { sendFile } from '@tinyhttp/send';
|
||||
import { setContentType, setHeader } from './headers.js';
|
||||
export const download = (req, res) => (path, filename, options, cb) => {
|
||||
let done = cb;
|
||||
let name = filename;
|
||||
let opts = (options || null);
|
||||
// support function as second or third arg
|
||||
if (typeof filename === 'function') {
|
||||
done = filename;
|
||||
name = null;
|
||||
}
|
||||
else if (typeof options === 'function') {
|
||||
done = options;
|
||||
opts = null;
|
||||
}
|
||||
// set Content-Disposition when file is sent
|
||||
const headers = {
|
||||
'Content-Disposition': contentDisposition(name || basename(path))
|
||||
};
|
||||
// merge user-provided headers
|
||||
if (opts === null || opts === void 0 ? void 0 : opts.headers) {
|
||||
for (const key of Object.keys(opts.headers)) {
|
||||
if (key.toLowerCase() !== 'content-disposition')
|
||||
headers[key] = opts.headers[key];
|
||||
}
|
||||
}
|
||||
// merge user-provided options
|
||||
opts = { ...opts, headers };
|
||||
// send file
|
||||
return sendFile(req, res)(opts.root ? path : resolve(path), opts, done || (() => undefined));
|
||||
};
|
||||
export const attachment = (res) => (filename) => {
|
||||
if (filename) {
|
||||
setContentType(res)(extname(filename));
|
||||
filename = basename(filename);
|
||||
}
|
||||
setHeader(res)('Content-Disposition', contentDisposition(filename));
|
||||
return res;
|
||||
};
|
||||
//# sourceMappingURL=download.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/download.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/download.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"download.js","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AASxD,MAAM,CAAC,MAAM,QAAQ,GACnB,CAAwD,GAAY,EAAE,GAAa,EAAE,EAAE,CACvF,CAAC,IAAY,EAAE,QAA4B,EAAE,OAAoC,EAAE,EAAa,EAAY,EAAE;IAC5G,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,IAAI,IAAI,GAAG,QAAyB,CAAA;IACpC,IAAI,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,CAA2B,CAAA;IAEtD,0CAA0C;IAC1C,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,IAAI,GAAG,QAAQ,CAAA;QACf,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;SAAM,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QACzC,IAAI,GAAG,OAAO,CAAA;QACd,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IAED,4CAA4C;IAC5C,MAAM,OAAO,GAAG;QACd,qBAAqB,EAAE,kBAAkB,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;KAClE,CAAA;IAED,8BAA8B;IAC9B,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,EAAE,CAAC;QAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5C,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,qBAAqB;gBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAA;IAE3B,YAAY;IAEZ,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;AAC9F,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,UAAU,GACrB,CAAuB,GAAa,EAAE,EAAE,CACxC,CAAC,QAAiB,EAAY,EAAE;IAC9B,IAAI,QAAQ,EAAE,CAAC;QACb,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;QACtC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAED,SAAS,CAAC,GAAG,CAAC,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEnE,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
||||
13
25_02_24/node_modules/@tinyhttp/res/dist/format.d.ts
generated
vendored
Normal file
13
25_02_24/node_modules/@tinyhttp/res/dist/format.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { IncomingMessage as Req, ServerResponse as Res } from 'node:http';
|
||||
export type FormatProps = {
|
||||
default?: () => void;
|
||||
} & Record<string, any>;
|
||||
export type FormatError = Error & {
|
||||
status: number;
|
||||
statusCode: number;
|
||||
types: string[];
|
||||
};
|
||||
type next = (err?: FormatError) => void;
|
||||
export declare const formatResponse: <Request extends Req = Req, Response extends Res = Res<Req>, Next extends next = next>(req: Request, res: Response, next: Next) => (obj: FormatProps) => Response;
|
||||
export {};
|
||||
//# sourceMappingURL=format.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/format.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/format.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,GAAG,EAAE,cAAc,IAAI,GAAG,EAAE,MAAM,WAAW,CAAA;AAK9E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAEvB,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,WAAW,KAAK,IAAI,CAAA;AAEvC,eAAO,MAAM,cAAc,GACxB,OAAO,SAAS,GAAG,QAAQ,QAAQ,SAAS,GAAG,aAAQ,IAAI,SAAS,IAAI,cAClE,OAAO,OACP,QAAQ,QACP,IAAI,WAEN,WAAW,KAAG,QAyBnB,CAAA"}
|
||||
26
25_02_24/node_modules/@tinyhttp/res/dist/format.js
generated
vendored
Normal file
26
25_02_24/node_modules/@tinyhttp/res/dist/format.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { getAccepts } from '@tinyhttp/req';
|
||||
import { setVaryHeader } from './headers.js';
|
||||
import { normalizeType, normalizeTypes } from './util.js';
|
||||
export const formatResponse = (req, res, next) => (obj) => {
|
||||
const fn = obj.default;
|
||||
if (fn)
|
||||
obj.default = undefined;
|
||||
const keys = Object.keys(obj);
|
||||
const key = keys.length > 0 ? getAccepts(req)(...keys) : false;
|
||||
setVaryHeader(res)('Accept');
|
||||
if (key) {
|
||||
res.setHeader('Content-Type', normalizeType(key).value);
|
||||
obj[key](req, res, next);
|
||||
}
|
||||
else if (fn) {
|
||||
fn();
|
||||
}
|
||||
else {
|
||||
const err = new Error('Not Acceptable');
|
||||
err.status = err.statusCode = 406;
|
||||
err.types = normalizeTypes(keys).map((o) => o.value);
|
||||
next(err);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
//# sourceMappingURL=format.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/format.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/format.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAczD,MAAM,CAAC,MAAM,cAAc,GACzB,CACE,GAAY,EACZ,GAAa,EACb,IAAU,EACV,EAAE,CACJ,CAAC,GAAgB,EAAY,EAAE;IAC7B,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAA;IAEtB,IAAI,EAAE;QAAE,GAAG,CAAC,OAAO,GAAG,SAAS,CAAA;IAE/B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAE7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAY,CAAC,CAAC,CAAC,KAAK,CAAA;IAE1E,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;IAE5B,IAAI,GAAG,EAAE,CAAC;QACR,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;QACvD,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAC1B,CAAC;SAAM,IAAI,EAAE,EAAE,CAAC;QACd,EAAE,EAAE,CAAA;IACN,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,gBAAgB,CAAgB,CAAA;QACtD,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,UAAU,GAAG,GAAG,CAAA;QACjC,GAAG,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QAEpD,IAAI,CAAC,GAAG,CAAC,CAAA;IACX,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
||||
11
25_02_24/node_modules/@tinyhttp/res/dist/headers.d.ts
generated
vendored
Normal file
11
25_02_24/node_modules/@tinyhttp/res/dist/headers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { OutgoingHttpHeaders } from 'node:http';
|
||||
import type { IncomingMessage as Req, ServerResponse as Res } from 'node:http';
|
||||
export declare const setHeader: <Response extends Res = Res<Req>>(res: Response) => (field: string | Record<string, string | number | string[]>, val?: string | number | readonly string[]) => Response;
|
||||
export declare const setLocationHeader: <Request extends Req = Req, Response extends Res = Res<Req>>(req: Request, res: Response) => (url: string) => Response;
|
||||
export declare const getResponseHeader: <Response extends Res = Res<Req>>(res: Response) => <HeaderName extends string>(field: HeaderName) => OutgoingHttpHeaders[HeaderName];
|
||||
export declare const setLinksHeader: <Response extends Res = Res<Req>>(res: Response) => (links: {
|
||||
[key: string]: string;
|
||||
}) => Response;
|
||||
export declare const setVaryHeader: <Response extends Res = Res<Req>>(res: Response) => (field: string) => Response;
|
||||
export declare const setContentType: <Response extends Res = Res<Req>>(res: Response) => (type: string) => Response;
|
||||
//# sourceMappingURL=headers.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/headers.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/headers.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,IAAI,GAAG,EAAE,cAAc,IAAI,GAAG,EAAE,MAAM,WAAW,CAAA;AAQ9E,eAAO,MAAM,SAAS,GACnB,QAAQ,SAAS,GAAG,kBAAa,QAAQ,aAClC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,MAAM,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,KAAG,QAwBxG,CAAA;AAEH,eAAO,MAAM,iBAAiB,GAC3B,OAAO,SAAS,GAAG,QAAQ,QAAQ,SAAS,GAAG,kBAAa,OAAO,OAAO,QAAQ,WAC7E,MAAM,KAAG,QASd,CAAA;AAEH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,SAAS,GAAG,kBAAa,QAAQ,MACjE,UAAU,SAAS,MAAM,SAAS,UAAU,KAAG,mBAAmB,CAAC,UAAU,CAGtF,CAAA;AAED,eAAO,MAAM,cAAc,GACxB,QAAQ,SAAS,GAAG,kBAAa,QAAQ,aAClC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,KAAG,QAYnC,CAAA;AAEH,eAAO,MAAM,aAAa,GACvB,QAAQ,SAAS,GAAG,kBAAa,QAAQ,aAClC,MAAM,KAAG,QAIhB,CAAA;AAEH,eAAO,MAAM,cAAc,GACxB,QAAQ,SAAS,GAAG,kBAAa,QAAQ,YACnC,MAAM,KAAG,QAMf,CAAA"}
|
||||
62
25_02_24/node_modules/@tinyhttp/res/dist/headers.js
generated
vendored
Normal file
62
25_02_24/node_modules/@tinyhttp/res/dist/headers.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import { encodeUrl } from '@tinyhttp/encode-url';
|
||||
import { getRequestHeader } from '@tinyhttp/req';
|
||||
import { vary } from '@tinyhttp/vary';
|
||||
import mime from 'mime';
|
||||
const charsetRegExp = /;\s*charset\s*=/;
|
||||
export const setHeader = (res) => (field, val) => {
|
||||
if (typeof field === 'string') {
|
||||
let value = Array.isArray(val) ? val.map(String) : String(val);
|
||||
// add charset to content-type
|
||||
if (field.toLowerCase() === 'content-type') {
|
||||
if (Array.isArray(value)) {
|
||||
throw new TypeError('Content-Type cannot be set to an Array');
|
||||
}
|
||||
if (!charsetRegExp.test(value)) {
|
||||
const charset = 'UTF-8'; // UTF-8 is the default charset for all types
|
||||
if (typeof charset === 'string')
|
||||
value += `; charset=${charset.toLowerCase()}`;
|
||||
}
|
||||
}
|
||||
res.setHeader(field, value);
|
||||
}
|
||||
else {
|
||||
for (const key in field) {
|
||||
setHeader(res)(key, field[key]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
export const setLocationHeader = (req, res) => (url) => {
|
||||
let loc = url;
|
||||
// "back" is an alias for the referrer
|
||||
if (url === 'back')
|
||||
loc = getRequestHeader(req)('Referrer') || '/';
|
||||
// set location
|
||||
res.setHeader('Location', encodeUrl(loc));
|
||||
return res;
|
||||
};
|
||||
export const getResponseHeader = (res) => {
|
||||
return (field) => {
|
||||
return res.getHeader(field);
|
||||
};
|
||||
};
|
||||
export const setLinksHeader = (res) => (links) => {
|
||||
let link = res.getHeader('Link') || '';
|
||||
if (link)
|
||||
link += ', ';
|
||||
res.setHeader('Link', link +
|
||||
Object.keys(links)
|
||||
.map((rel) => `<${links[rel]}>; rel="${rel}"`)
|
||||
.join(', '));
|
||||
return res;
|
||||
};
|
||||
export const setVaryHeader = (res) => (field) => {
|
||||
vary(res, field);
|
||||
return res;
|
||||
};
|
||||
export const setContentType = (res) => (type) => {
|
||||
const ct = type.indexOf('/') === -1 ? mime.getType(type) : type;
|
||||
setHeader(res)('Content-Type', ct);
|
||||
return res;
|
||||
};
|
||||
//# sourceMappingURL=headers.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/headers.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/headers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACrC,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,aAAa,GAAG,iBAAiB,CAAA;AAEvC,MAAM,CAAC,MAAM,SAAS,GACpB,CAA6B,GAAa,EAAE,EAAE,CAC9C,CAAC,KAA0D,EAAE,GAAyC,EAAY,EAAE;IAClH,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAE9D,8BAA8B;QAC9B,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;YAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAA;YAC/D,CAAC;YAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAA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IAAI,EAAE,CAAA;IACtC,IAAI,IAAI;QAAE,IAAI,IAAI,IAAI,CAAA;IACtB,GAAG,CAAC,SAAS,CACX,MAAM,EACN,IAAI;QACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACf,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC;aAC7C,IAAI,CAAC,IAAI,CAAC,CAChB,CAAA;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,aAAa,GACxB,CAA6B,GAAa,EAAE,EAAE,CAC9C,CAAC,KAAa,EAAY,EAAE;IAC1B,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAEhB,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,cAAc,GACzB,CAA6B,GAAa,EAAE,EAAE,CAC9C,CAAC,IAAY,EAAY,EAAE;IACzB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAE/D,SAAS,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAY,CAAC,CAAA;IAE5C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
||||
9
25_02_24/node_modules/@tinyhttp/res/dist/index.d.ts
generated
vendored
Normal file
9
25_02_24/node_modules/@tinyhttp/res/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export * from '@tinyhttp/send';
|
||||
export * from './cookie.js';
|
||||
export { setContentType, setHeader, setLinksHeader, setLocationHeader, setVaryHeader, getResponseHeader } from './headers.js';
|
||||
export type { FormatProps, FormatError } from './format.js';
|
||||
export { formatResponse } from './format.js';
|
||||
export { redirect } from './redirect.js';
|
||||
export * from './download.js';
|
||||
export { append } from './append.js';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/index.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EACL,cAAc,EACd,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EAClB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
||||
8
25_02_24/node_modules/@tinyhttp/res/dist/index.js
generated
vendored
Normal file
8
25_02_24/node_modules/@tinyhttp/res/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export * from '@tinyhttp/send';
|
||||
export * from './cookie.js';
|
||||
export { setContentType, setHeader, setLinksHeader, setLocationHeader, setVaryHeader, getResponseHeader } from './headers.js';
|
||||
export { formatResponse } from './format.js';
|
||||
export { redirect } from './redirect.js';
|
||||
export * from './download.js';
|
||||
export { append } from './append.js';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/index.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EACL,cAAc,EACd,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
||||
5
25_02_24/node_modules/@tinyhttp/res/dist/redirect.d.ts
generated
vendored
Normal file
5
25_02_24/node_modules/@tinyhttp/res/dist/redirect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { type IncomingMessage as Req, type ServerResponse as Res } from 'node:http';
|
||||
type next = (err?: any) => void;
|
||||
export declare const redirect: <Request extends Req = Req, Response extends Res = Res<Req>, Next extends next = next>(req: Request, res: Response, next: Next) => (url: string, status?: number) => Response;
|
||||
export {};
|
||||
//# sourceMappingURL=redirect.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/redirect.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/redirect.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../src/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,IAAI,GAAG,EAAE,KAAK,cAAc,IAAI,GAAG,EAAgB,MAAM,WAAW,CAAA;AAKjG,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;AAE/B,eAAO,MAAM,QAAQ,GAClB,OAAO,SAAS,GAAG,QAAQ,QAAQ,SAAS,GAAG,aAAQ,IAAI,SAAS,IAAI,cAClE,OAAO,OACP,QAAQ,QACP,IAAI,WAEN,MAAM,WAAW,MAAM,KAAG,QAkC/B,CAAA"}
|
||||
30
25_02_24/node_modules/@tinyhttp/res/dist/redirect.js
generated
vendored
Normal file
30
25_02_24/node_modules/@tinyhttp/res/dist/redirect.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { STATUS_CODES } from 'node:http';
|
||||
import { formatResponse } from './format.js';
|
||||
import { setLocationHeader } from './headers.js';
|
||||
import { escapeHTML } from './util.js';
|
||||
export const redirect = (req, res, next) => (url, status) => {
|
||||
let address = url;
|
||||
status = status || 302;
|
||||
let body = '';
|
||||
address = setLocationHeader(req, res)(address).getHeader('Location');
|
||||
formatResponse(req, res, next)({
|
||||
text: () => {
|
||||
body = `${STATUS_CODES[status]}. Redirecting to ${address}`;
|
||||
},
|
||||
html: () => {
|
||||
const u = escapeHTML(address);
|
||||
body = `<p>${STATUS_CODES[status]}. Redirecting to <a href="${u}">${u}</a></p>`;
|
||||
},
|
||||
default: () => {
|
||||
body = '';
|
||||
}
|
||||
});
|
||||
res.setHeader('Content-Length', Buffer.byteLength(body));
|
||||
res.statusCode = status;
|
||||
if (req.method === 'HEAD')
|
||||
res.end();
|
||||
else
|
||||
res.end(body);
|
||||
return res;
|
||||
};
|
||||
//# sourceMappingURL=redirect.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/redirect.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/redirect.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"redirect.js","sourceRoot":"","sources":["../src/redirect.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2D,YAAY,EAAE,MAAM,WAAW,CAAA;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAItC,MAAM,CAAC,MAAM,QAAQ,GACnB,CACE,GAAY,EACZ,GAAa,EACb,IAAU,EACV,EAAE,CACJ,CAAC,GAAW,EAAE,MAAe,EAAY,EAAE;IACzC,IAAI,OAAO,GAAG,GAAG,CAAA;IACjB,MAAM,GAAG,MAAM,IAAI,GAAG,CAAA;IAEtB,IAAI,IAAI,GAAG,EAAE,CAAA;IAEb,OAAO,GAAG,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,UAAU,CAAW,CAAA;IAE9E,cAAc,CACZ,GAAG,EACH,GAAG,EACH,IAAI,CACL,CAAC;QACA,IAAI,EAAE,GAAG,EAAE;YACT,IAAI,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,oBAAoB,OAAO,EAAE,CAAA;QAC7D,CAAC;QACD,IAAI,EAAE,GAAG,EAAE;YACT,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;YAE7B,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,6BAA6B,CAAC,KAAK,CAAC,UAAU,CAAA;QACjF,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,GAAG,EAAE,CAAA;QACX,CAAC;KACF,CAAC,CAAA;IAEF,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;IAExD,GAAG,CAAC,UAAU,GAAG,MAAM,CAAA;IAEvB,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;QAAE,GAAG,CAAC,GAAG,EAAE,CAAA;;QAC/B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAElB,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
||||
11
25_02_24/node_modules/@tinyhttp/res/dist/util.d.ts
generated
vendored
Normal file
11
25_02_24/node_modules/@tinyhttp/res/dist/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export type NormalizedType = {
|
||||
value: string;
|
||||
quality?: number;
|
||||
params: Record<string, string>;
|
||||
originalIndex?: number;
|
||||
};
|
||||
export declare function acceptParams(str: string, index?: number): NormalizedType;
|
||||
export declare const normalizeType: (type: string) => NormalizedType;
|
||||
export declare function normalizeTypes(types: string[]): NormalizedType[];
|
||||
export declare function escapeHTML(str: string): string;
|
||||
//# sourceMappingURL=util.d.ts.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/util.d.ts.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/util.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,cAAc,CAWxE;AAED,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,cAC4D,CAAA;AAEzG,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAQhE;AAID,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAyC9C"}
|
||||
60
25_02_24/node_modules/@tinyhttp/res/dist/util.js
generated
vendored
Normal file
60
25_02_24/node_modules/@tinyhttp/res/dist/util.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import mime from 'mime';
|
||||
export function acceptParams(str, index) {
|
||||
const parts = str.split(/ *; */);
|
||||
const ret = { value: parts[0], quality: 1, params: {}, originalIndex: index };
|
||||
for (const part of parts) {
|
||||
const pms = part.split(/ *= */);
|
||||
if ('q' === pms[0])
|
||||
ret.quality = Number.parseFloat(pms[1]);
|
||||
else
|
||||
ret.params[pms[0]] = pms[1];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
export const normalizeType = (type) => ~type.indexOf('/') ? acceptParams(type) : { value: mime.getType(type), params: {} };
|
||||
export function normalizeTypes(types) {
|
||||
const ret = [];
|
||||
for (const type of types) {
|
||||
ret.push(normalizeType(type));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
const matchHtmlRegExp = /["'&<>]/;
|
||||
export function escapeHTML(str) {
|
||||
const match = matchHtmlRegExp.exec(str);
|
||||
if (!match) {
|
||||
// stringify in case input is not a string
|
||||
return String(str);
|
||||
}
|
||||
let escapeChar;
|
||||
let html = '';
|
||||
let index = 0;
|
||||
let lastIndex = 0;
|
||||
for (index = match.index; index < str.length; index++) {
|
||||
switch (str.charCodeAt(index)) {
|
||||
case 34: // "
|
||||
escapeChar = '"';
|
||||
break;
|
||||
case 38: // &
|
||||
escapeChar = '&';
|
||||
break;
|
||||
case 39: // '
|
||||
escapeChar = ''';
|
||||
break;
|
||||
case 60: // <
|
||||
escapeChar = '<';
|
||||
break;
|
||||
case 62: // >
|
||||
escapeChar = '>';
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (lastIndex !== index)
|
||||
html += str.substring(lastIndex, index);
|
||||
lastIndex = index + 1;
|
||||
html += escapeChar;
|
||||
}
|
||||
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
||||
}
|
||||
//# sourceMappingURL=util.js.map
|
||||
1
25_02_24/node_modules/@tinyhttp/res/dist/util.js.map
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/dist/util.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AASvB,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,KAAc;IACtD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,GAAG,GAAmB,EAAE,KAAK,EAAE,KAAK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AA;IACpB,CAAC;IAED,IAAI,UAAkB,CAAA;IACtB,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,SAAS,GAAG,CAAC,CAAA;IAEjB,KAAK,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,QAAQ,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,KAAK,EAAE,EAAE,IAAI;gBACX,UAAU,GAAG,QAAQ,CAAA;gBACrB,MAAK;YACP,KAAK,EAAE,EAAE,IAAI;gBACX,UAAU,GAAG,OAAO,CAAA;gBACpB,MAAK;YACP,KAAK,EAAE,EAAE,IAAI;gBACX,UAAU,GAAG,OAAO,CAAA;gBACpB,MAAK;YACP,KAAK,EAAE,EAAE,IAAI;gBACX,UAAU,GAAG,MAAM,CAAA;gBACnB,MAAK;YACP,KAAK,EAAE,EAAE,IAAI;gBACX,UAAU,GAAG,MAAM,CAAA;gBACnB,MAAK;YACP;gBACE,SAAQ;QACZ,CAAC;QAED,IAAI,SAAS,KAAK,KAAK;YAAE,IAAI,IAAI,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAEhE,SAAS,GAAG,KAAK,GAAG,CAAC,CAAA;QACrB,IAAI,IAAI,UAAU,CAAA;IACpB,CAAC;IAED,OAAO,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5E,CAAC"}
|
||||
41
25_02_24/node_modules/@tinyhttp/res/package.json
generated
vendored
Normal file
41
25_02_24/node_modules/@tinyhttp/res/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "@tinyhttp/res",
|
||||
"version": "2.2.5",
|
||||
"type": "module",
|
||||
"description": "response extensions for tinyhttp",
|
||||
"homepage": "https://tinyhttp.v1rtl.site",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tinyhttp/tinyhttp.git",
|
||||
"directory": "packages/res"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": "./dist/index.js",
|
||||
"keywords": [
|
||||
"tinyhttp",
|
||||
"node.js",
|
||||
"web framework",
|
||||
"web",
|
||||
"backend",
|
||||
"res"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
},
|
||||
"author": "v1rtl",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tinyhttp/vary": "^0.1.3",
|
||||
"es-escape-html": "^0.1.1",
|
||||
"mime": "4.0.4",
|
||||
"@tinyhttp/content-disposition": "2.2.2",
|
||||
"@tinyhttp/cookie": "2.1.1",
|
||||
"@tinyhttp/cookie-signature": "2.1.1",
|
||||
"@tinyhttp/encode-url": "2.1.1",
|
||||
"@tinyhttp/req": "2.2.5",
|
||||
"@tinyhttp/send": "2.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
}
|
||||
}
|
||||
1
25_02_24/node_modules/@tinyhttp/res/tsconfig.tsbuildinfo
generated
vendored
Normal file
1
25_02_24/node_modules/@tinyhttp/res/tsconfig.tsbuildinfo
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user