node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

21
server/node_modules/koa-body/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Charlike Mike Reagent <mameto_100@mail.bg> and Daryl Lau <daryl@weak.io>
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.

193
server/node_modules/koa-body/README.md generated vendored Normal file
View File

@@ -0,0 +1,193 @@
# koa-body
[![CI](https://github.com/koajs/koa-body/actions/workflows/ci.yaml/badge.svg)](https://github.com/koajs/koa-body/actions/workflows/ci.yaml)
[![KoaJs Slack](https://img.shields.io/badge/Koa.Js-Slack%20Channel-Slack.svg?longCache=true)](https://communityinviter.com/apps/koa-js/koajs)
---
> A full-featured [`koa`](https://github.com/koajs/koa) body parser middleware. Supports `multipart`, `urlencoded`, and `json` request bodies. Provides the same functionality as Express's bodyParser - [`multer`](https://github.com/expressjs/multer).
## Install
> Install with [npm](https://github.com/npm/npm)
```
npm install koa-body
```
## Features
- can handle requests such as:
- **multipart/form-data**
- **application/x-www-form-urlencoded**
- **application/json**
- **application/json-patch+json**
- **application/vnd.api+json**
- **application/csp-report**
- **text/xml**
- option for patch to Koa or Node, or either
- file uploads
- body, fields and files size limiting
## Hello World - Quickstart
```sh
npm install koa koa-body # Note that Koa requires Node.js 7.6.0+ for async/await support
```
index.js:
```js
const Koa = require('koa');
const { koaBody } = require('koa-body');
const app = new Koa();
app.use(koaBody());
app.use((ctx) => {
ctx.body = `Request Body: ${JSON.stringify(ctx.request.body)}`;
});
app.listen(3000);
```
```sh
node index.js
curl -i http://localhost:3000/users -d "name=test"
```
Output:
```text
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 29
Date: Wed, 03 May 2017 02:09:44 GMT
Connection: keep-alive
Request Body: {"name":"test"}%
```
**For a more comprehensive example, see** `examples/multipart.js`
## Usage with [koa-router](https://github.com/alexmingoia/koa-router)
It's generally better to only parse the body as needed, if using a router that supports middleware composition, we can inject it only for certain routes.
```js
const Koa = require('koa');
const app = new Koa();
const router = require('koa-router')();
const { koaBody } = require('koa-body');
router.post('/users', koaBody(), (ctx) => {
console.log(ctx.request.body);
// => POST body
ctx.body = JSON.stringify(ctx.request.body);
});
app.use(router.routes());
app.listen(3000);
console.log('curl -i http://localhost:3000/users -d "name=test"');
```
## Usage with unsupported text body type
For unsupported text body type, for example, `text/xml`, you can use the unparsed request body at `ctx.request.body`. For the text content type, the `includeUnparsed` setting is not required.
```js
// xml-parse.js:
const Koa = require('koa');
const { koaBody } = require('koa-body');
const convert = require('xml-js');
const app = new Koa();
app.use(koaBody());
app.use((ctx) => {
const obj = convert.xml2js(ctx.request.body);
ctx.body = `Request Body: ${JSON.stringify(obj)}`;
});
app.listen(3000);
```
```sh
node xml-parse.js
curl -i http://localhost:3000/users -H "Content-Type: text/xml" -d '<?xml version="1.0"?><catalog id="1"></catalog>'
```
Output:
```text
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 135
Date: Tue, 09 Jun 2020 11:17:38 GMT
Connection: keep-alive
Request Body: {"declaration":{"attributes":{"version":"1.0"}},"elements":[{"type":"element","name":"catalog","attributes":{"id":"1"}}]}%
```
## Options
> Options available for `koa-body`. Four custom options, and others are from `raw-body` and `formidable`.
- `patchNode` **{Boolean}** Patch request body to Node's `ctx.req`, default `false`
- `patchKoa` **{Boolean}** Patch request body to Koa's `ctx.request`, default `true`
- `jsonLimit` **{String|Integer}** The byte (if integer) limit of the JSON body, default `1mb`
- `formLimit` **{String|Integer}** The byte (if integer) limit of the form body, default `56kb`
- `textLimit` **{String|Integer}** The byte (if integer) limit of the text body, default `56kb`
- `encoding` **{String}** Sets encoding for incoming form fields, default `utf-8`
- `multipart` **{Boolean}** Parse multipart bodies, default `false`
- `urlencoded` **{Boolean}** Parse urlencoded bodies, default `true`
- `text` **{Boolean}** Parse text bodies, such as XML, default `true`
- `json` **{Boolean}** Parse JSON bodies, default `true`
- `jsonStrict` **{Boolean}** Toggles co-body strict mode; if set to true - only parses arrays or objects, default `true`
- `includeUnparsed` **{Boolean}** Toggles co-body returnRawBody option; if set to true, for form encoded and JSON requests the raw, unparsed request body will be attached to `ctx.request.body` using a `Symbol` ([see details](#a-note-about-unparsed-request-bodies)), default `false`
- `formidable` **{Object}** Options to pass to the formidable multipart parser
- `onError` **{Function}** Custom error handle, if throw an error, you can customize the response - onError(error, context), default will throw
- `parsedMethods` **{String[]}** Declares the HTTP methods where bodies will be parsed, default `['POST', 'PUT', 'PATCH']`. Replaces `strict` option.
## A note about `parsedMethods`
> see [http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.3](http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.3)
- `GET`, `HEAD`, and `DELETE` requests have no defined semantics for the request body, but this doesn't mean they may not be valid in certain use cases.
- koa-body is strict by default, parsing only `POST`, `PUT`, and `PATCH` requests
- you may use either the enumeration or strings to chose which methods to parse: For example, `HttpMethodEnum.PATCH`
## File Support
Uploaded files are accessible via `ctx.request.files`.
## A note about unparsed request bodies
Some applications require crytopgraphic verification of request bodies, for example webhooks from slack or stripe. The unparsed body can be accessed if `includeUnparsed` is `true` in koa-body's options. When enabled, import the symbol for accessing the request body from `unparsed = require('koa-body/unparsed.js')`, or define your own accessor using `unparsed = Symbol.for('unparsedBody')`. Then the unparsed body is available using `ctx.request.body[unparsed]`.
## Some options for formidable
> See [node-formidable](https://github.com/felixge/node-formidable) for a full list of options
- `maxFields` **{Integer}** Limits the number of fields that the querystring parser will decode, default `1000`
- `maxFieldsSize` **{Integer}** Limits the amount of memory all fields together (except files) can allocate in bytes. If this value is exceeded, an 'error' event is emitted, default `2mb (2 * 1024 * 1024)`
- `uploadDir` **{String}** Sets the directory for placing file uploads in, default `os.tmpDir()`
- `keepExtensions` **{Boolean}** Files written to `uploadDir` will include the extensions of the original files, default `false`
- `hashAlgorithm` **{String}** If you want checksums calculated for incoming files, set this to either `'sha1'` or `'md5'`, default `false`
- `multiples` **{Boolean}** Multiple file uploads or no, default `true`
- `onFileBegin` **{Function}** Special callback on file begin. The function is executed directly by formidable. It can be used to rename files before saving them to disk. [See the docs](https://github.com/felixge/node-formidable#filebegin)
## Changelog
Please see the [Changelog](./CHANGELOG.md) for a summary of changes.
## Tests
```
$ npm test
```
## License
The MIT License, 2014 [Charlike Mike Reagent](https://github.com/tunnckoCore) ([@tunnckoCore](https://twitter.com/tunnckoCore)) and [Daryl Lau](https://github.com/dlau) ([@daryllau](https://twitter.com/daryllau))

13
server/node_modules/koa-body/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import type { KoaBodyMiddlewareOptions } from './types';
import type { Middleware } from 'koa';
import * as Koa from 'koa';
import type { Files } from 'formidable';
export * from './types';
declare module 'koa' {
interface Request extends Koa.BaseRequest {
body?: any;
files?: Files;
}
}
export declare function koaBody(options?: Partial<KoaBodyMiddlewareOptions>): Middleware;
export default koaBody;

120
server/node_modules/koa-body/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,120 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.koaBody = void 0;
const types_1 = require("./types");
const co_body_1 = __importDefault(require("co-body"));
const string_method_to_enum_method_1 = __importDefault(require("./utils/string-method-to-enum-method"));
const throwable_to_error_1 = __importDefault(require("./utils/throwable-to-error"));
const body_type_util_1 = require("./utils/body-type-util");
const parse_with_formidable_1 = __importDefault(require("./utils/parse-with-formidable"));
const patch_util_1 = require("./utils/patch-util");
__exportStar(require("./types"), exports);
function koaBody(options = {}) {
const validatedOptions = types_1.KoaBodyMiddlewareOptionsSchema.parse(options);
const optionsToUse = { ...options, ...validatedOptions };
return async (ctx, next) => {
const isJson = (0, body_type_util_1.isJsonBody)(ctx, optionsToUse);
const isText = (0, body_type_util_1.isTextBody)(ctx, optionsToUse);
const isUrlencoded = (0, body_type_util_1.isUrlencodedBody)(ctx, optionsToUse);
const isMultipart = (0, body_type_util_1.isMultipartBody)(ctx, optionsToUse);
const { encoding, jsonStrict, jsonLimit, includeUnparsed: returnRawBody, formLimit, textLimit, queryString, formidable, onError, patchNode, patchKoa, } = optionsToUse;
// only parse the body on specifically chosen methods
if (validatedOptions.parsedMethods.includes((0, string_method_to_enum_method_1.default)(ctx.method.toUpperCase()))) {
try {
if (isJson) {
const jsonBody = await co_body_1.default.json(ctx, {
encoding,
limit: jsonLimit,
strict: jsonStrict,
returnRawBody,
});
(0, patch_util_1.patchNodeAndKoa)(ctx, jsonBody, {
isText,
includeUnparsed: returnRawBody,
isMultipart,
patchKoa,
patchNode,
});
}
else if (isUrlencoded) {
const urlEncodedBody = await co_body_1.default.form(ctx, {
encoding,
limit: formLimit,
queryString: queryString,
returnRawBody,
});
(0, patch_util_1.patchNodeAndKoa)(ctx, urlEncodedBody, {
isText,
includeUnparsed: returnRawBody,
isMultipart,
patchKoa,
patchNode,
});
}
else if (isText) {
const textBody = await co_body_1.default.text(ctx, {
encoding,
limit: textLimit,
returnRawBody,
});
(0, patch_util_1.patchNodeAndKoa)(ctx, textBody, {
isText,
includeUnparsed: returnRawBody,
isMultipart,
patchKoa,
patchNode,
});
}
else if (isMultipart) {
const multipartBody = await (0, parse_with_formidable_1.default)(ctx, formidable || {});
(0, patch_util_1.patchNodeAndKoa)(ctx, multipartBody, {
isText,
includeUnparsed: returnRawBody,
isMultipart,
patchKoa,
patchNode,
});
}
}
catch (parsingError) {
const error = (0, throwable_to_error_1.default)(parsingError);
if (typeof onError === 'function') {
onError(error, ctx);
}
else {
throw error;
}
}
}
else {
(0, patch_util_1.patchNodeAndKoa)(ctx, {}, {
isText,
includeUnparsed: returnRawBody,
isMultipart,
patchKoa,
patchNode,
});
}
return next();
};
}
exports.koaBody = koaBody;
exports.default = koaBody;
//# sourceMappingURL=index.js.map

1
server/node_modules/koa-body/lib/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,mCAAyD;AAKzD,sDAA6B;AAC7B,wGAAgE;AAChE,oFAA0D;AAC1D,2DAAmG;AACnG,0FAAgE;AAChE,mDAAqD;AAGrD,0CAAwB;AASxB,SAAgB,OAAO,CAAC,UAA6C,EAAE;IACrE,MAAM,gBAAgB,GAAG,sCAA8B,CAAC,KAAK,CAAC,OAAO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ChB,CAAC,CAAC;AACJ,CAAC;AAnGD,0BAmGC;AAED,kBAAe,OAAO,CAAC"}

127
server/node_modules/koa-body/lib/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,127 @@
import type { File, Options as FormidableOptions } from 'formidable';
import type { Options as CoBodyOptions } from 'co-body';
import type { Context } from 'koa';
import { z } from 'zod';
export declare enum HttpMethodEnum {
POST = "POST",
GET = "GET",
PUT = "PUT",
PATCH = "PATCH",
DELETE = "DELETE",
HEAD = "HEAD"
}
declare const HttpMethod: z.ZodNativeEnum<typeof HttpMethodEnum>;
export declare type HttpMethod = z.infer<typeof HttpMethod>;
export declare type ExtendedFormidableOptions = FormidableOptions & {
onFileBegin?: (name: string, file: File) => void;
};
export declare const KoaBodyMiddlewareOptionsSchema: z.ZodObject<{
/**
* {Boolean} Patch request body to Node's ctx.req, default false
*
* Note: You can patch request body to Node or Koa in same time if you want.
*/
patchNode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* {Boolean} Patch request body to Koa's ctx.request, default true
*
* Note: You can patch request body to Node or Koa in same time if you want.
*/
patchKoa: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* {String|Integer} The byte (if integer) limit of the JSON body, default 1mb
*/
jsonLimit: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
/**
* {String|Integer} The byte (if integer) limit of the form body, default 56kb
*/
formLimit: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
/**
* {String|Integer} The byte (if integer) limit of the text body, default 56kb
*/
textLimit: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
/**
* {String} Sets encoding for incoming form fields, default utf-8
*/
encoding: z.ZodDefault<z.ZodOptional<z.ZodString>>;
/**
* {Boolean} Parse multipart bodies, default false
*/
multipart: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* {Boolean} Parse urlencoded bodies, default true
*/
urlencoded: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* {Boolean} Parse text bodies, default true
*/
text: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* {Boolean} Parse json bodies, default true
*/
json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* Toggles co-body strict mode; if true, only parses arrays or objects, default true
*/
jsonStrict: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* Toggles co-body returnRawBody mode; if true,
* the raw body will be available using a Symbol for 'unparsedBody'.
*
* ```
// Either:
const unparsed = require('koa-body/unparsed.js');
const unparsed = Symbol.for('unparsedBody');
// Then later, to access:
ctx.request.body[unparsed]
```
* default false
*/
includeUnparsed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* {String[]} What HTTP methods to enable body parsing for; should be used in preference to strict mode.
*
* GET, HEAD, and DELETE requests have no defined semantics for the request body,
* but this doesn't mean they may not be valid in certain use cases.
* koa-body will only parse HTTP request bodies for POST, PUT, and PATCH by default
*
* see http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.3
*/
parsedMethods: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof HttpMethodEnum>, "many">>>;
}, "strip", z.ZodTypeAny, {
json: boolean;
encoding: string;
multipart: boolean;
patchNode: boolean;
patchKoa: boolean;
jsonLimit: string | number;
formLimit: string | number;
textLimit: string | number;
urlencoded: boolean;
text: boolean;
jsonStrict: boolean;
includeUnparsed: boolean;
parsedMethods: HttpMethodEnum[];
}, {
json?: boolean | undefined;
encoding?: string | undefined;
multipart?: boolean | undefined;
patchNode?: boolean | undefined;
patchKoa?: boolean | undefined;
jsonLimit?: string | number | undefined;
formLimit?: string | number | undefined;
textLimit?: string | number | undefined;
urlencoded?: boolean | undefined;
text?: boolean | undefined;
jsonStrict?: boolean | undefined;
includeUnparsed?: boolean | undefined;
parsedMethods?: HttpMethodEnum[] | undefined;
}>;
export declare type KoaBodyDirectOptions = z.infer<typeof KoaBodyMiddlewareOptionsSchema>;
export declare type KoaBodyMiddlewareOptions = KoaBodyDirectOptions & {
onError?: (err: Error, ctx: Context) => void;
formidable?: ExtendedFormidableOptions;
queryString?: CoBodyOptions['queryString'];
};
export {};

93
server/node_modules/koa-body/lib/types.js generated vendored Normal file
View File

@@ -0,0 +1,93 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KoaBodyMiddlewareOptionsSchema = exports.HttpMethodEnum = void 0;
const zod_1 = require("zod");
var HttpMethodEnum;
(function (HttpMethodEnum) {
HttpMethodEnum["POST"] = "POST";
HttpMethodEnum["GET"] = "GET";
HttpMethodEnum["PUT"] = "PUT";
HttpMethodEnum["PATCH"] = "PATCH";
HttpMethodEnum["DELETE"] = "DELETE";
HttpMethodEnum["HEAD"] = "HEAD";
})(HttpMethodEnum = exports.HttpMethodEnum || (exports.HttpMethodEnum = {}));
const HttpMethod = zod_1.z.nativeEnum(HttpMethodEnum);
exports.KoaBodyMiddlewareOptionsSchema = zod_1.z.object({
/**
* {Boolean} Patch request body to Node's ctx.req, default false
*
* Note: You can patch request body to Node or Koa in same time if you want.
*/
patchNode: zod_1.z.boolean().optional().default(false),
/**
* {Boolean} Patch request body to Koa's ctx.request, default true
*
* Note: You can patch request body to Node or Koa in same time if you want.
*/
patchKoa: zod_1.z.boolean().optional().default(true),
/**
* {String|Integer} The byte (if integer) limit of the JSON body, default 1mb
*/
jsonLimit: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional().default('1mb'),
/**
* {String|Integer} The byte (if integer) limit of the form body, default 56kb
*/
formLimit: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional().default('56kb'),
/**
* {String|Integer} The byte (if integer) limit of the text body, default 56kb
*/
textLimit: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional().default('56kb'),
/**
* {String} Sets encoding for incoming form fields, default utf-8
*/
encoding: zod_1.z.string().optional().default('utf-8'),
/**
* {Boolean} Parse multipart bodies, default false
*/
multipart: zod_1.z.boolean().optional().default(false),
/**
* {Boolean} Parse urlencoded bodies, default true
*/
urlencoded: zod_1.z.boolean().optional().default(true),
/**
* {Boolean} Parse text bodies, default true
*/
text: zod_1.z.boolean().optional().default(true),
/**
* {Boolean} Parse json bodies, default true
*/
json: zod_1.z.boolean().optional().default(true),
/**
* Toggles co-body strict mode; if true, only parses arrays or objects, default true
*/
jsonStrict: zod_1.z.boolean().optional().default(true),
/**
* Toggles co-body returnRawBody mode; if true,
* the raw body will be available using a Symbol for 'unparsedBody'.
*
* ```
// Either:
const unparsed = require('koa-body/unparsed.js');
const unparsed = Symbol.for('unparsedBody');
// Then later, to access:
ctx.request.body[unparsed]
```
* default false
*/
includeUnparsed: zod_1.z.boolean().optional().default(false),
/**
* {String[]} What HTTP methods to enable body parsing for; should be used in preference to strict mode.
*
* GET, HEAD, and DELETE requests have no defined semantics for the request body,
* but this doesn't mean they may not be valid in certain use cases.
* koa-body will only parse HTTP request bodies for POST, PUT, and PATCH by default
*
* see http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.3
*/
parsedMethods: zod_1.z
.array(HttpMethod)
.optional()
.default([HttpMethodEnum.POST, HttpMethodEnum.PUT, HttpMethodEnum.PATCH]),
});
//# sourceMappingURL=types.js.map

1
server/node_modules/koa-body/lib/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAGA,6BAAwB;AAExB,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,6BAAW,CAAA;IACX,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,+BAAa,CAAA;AACf,CAAC,EAPW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAOzB;AAED,MAAM,UAAU,GAAG,OAAC,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAOnC,QAAA,8BAA8B,GAAG,OAAC,CAAC,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QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1C;;OAEG;IACH,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAEhD;;;;;;;;;;;;;SAaK;IACL,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAEtD;;;;;;;;OAQG;IACH,aAAa,EAAE,OAAC;SACb,KAAK,CAAC,UAAU,CAAC;SACjB,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CAC5E,CAAC,CAAC"}

2
server/node_modules/koa-body/lib/unparsed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const _default: symbol;
export default _default;

4
server/node_modules/koa-body/lib/unparsed.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Symbol.for('unparsedBody');
//# sourceMappingURL=unparsed.js.map

1
server/node_modules/koa-body/lib/unparsed.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"unparsed.js","sourceRoot":"","sources":["../src/unparsed.ts"],"names":[],"mappings":";;AAAA,kBAAe,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC"}

View File

@@ -0,0 +1,6 @@
import type { KoaBodyMiddlewareOptions } from '../types';
import type { Context } from 'koa';
export declare function isJsonBody(ctx: Context, options: KoaBodyMiddlewareOptions): string | false | null;
export declare function isUrlencodedBody(ctx: Context, options: KoaBodyMiddlewareOptions): string | false | null;
export declare function isTextBody(ctx: Context, options: KoaBodyMiddlewareOptions): string | false | null;
export declare function isMultipartBody(ctx: Context, options: KoaBodyMiddlewareOptions): string | false | null;

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMultipartBody = exports.isTextBody = exports.isUrlencodedBody = exports.isJsonBody = void 0;
const jsonTypes = [
'application/json',
'application/json-patch+json',
'application/vnd.api+json',
'application/csp-report',
'application/reports+json',
];
function isJsonBody(ctx, options) {
return options.json && ctx.is(jsonTypes);
}
exports.isJsonBody = isJsonBody;
function isUrlencodedBody(ctx, options) {
return options.urlencoded && ctx.is('urlencoded');
}
exports.isUrlencodedBody = isUrlencodedBody;
function isTextBody(ctx, options) {
return options.text && ctx.is('text/*');
}
exports.isTextBody = isTextBody;
function isMultipartBody(ctx, options) {
return options.multipart && ctx.is('multipart');
}
exports.isMultipartBody = isMultipartBody;
//# sourceMappingURL=body-type-util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"body-type-util.js","sourceRoot":"","sources":["../../src/utils/body-type-util.ts"],"names":[],"mappings":";;;AAGA,MAAM,SAAS,GAAG;IAChB,kBAAkB;IAClB,6BAA6B;IAC7B,0BAA0B;IAC1B,wBAAwB;IACxB,0BAA0B;CAC3B,CAAC;AAEF,SAAgB,UAAU,CAAC,GAAY,EAAE,OAAiC;IACxE,OAAO,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAFD,gCAEC;AAED,SAAgB,gBAAgB,CAAC,GAAY,EAAE,OAAiC;IAC9E,OAAO,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;AACpD,CAAC;AAFD,4CAEC;AAED,SAAgB,UAAU,CAAC,GAAY,EAAE,OAAiC;IACxE,OAAO,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAFD,gCAEC;AAED,SAAgB,eAAe,CAAC,GAAY,EAAE,OAAiC;IAC7E,OAAO,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC;AAFD,0CAEC"}

View File

@@ -0,0 +1,8 @@
import type { Fields, Files } from 'formidable';
import type { Context } from 'koa';
import type { ExtendedFormidableOptions } from '../types';
export declare type ParseWithFormidableResult = {
fields: Fields;
files: Files;
};
export default function parseWithFormidable(ctx: Context, options: ExtendedFormidableOptions): Promise<ParseWithFormidableResult>;

View File

@@ -0,0 +1,24 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const formidable_1 = __importDefault(require("formidable"));
function parseWithFormidable(ctx, options) {
const { onFileBegin, ...directOptions } = options;
const form = (0, formidable_1.default)({ multiples: true, ...directOptions });
if (onFileBegin) {
form.on('fileBegin', onFileBegin);
}
return new Promise((resolve, reject) => {
form.parse(ctx.req, (error, fields, files) => {
if (error) {
reject(error);
return;
}
resolve({ fields, files });
});
});
}
exports.default = parseWithFormidable;
//# sourceMappingURL=parse-with-formidable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parse-with-formidable.js","sourceRoot":"","sources":["../../src/utils/parse-with-formidable.ts"],"names":[],"mappings":";;;;;AACA,4DAAoC;AASpC,SAAwB,mBAAmB,CACzC,GAAY,EACZ,OAAkC;IAElC,MAAM,EAAE,WAAW,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,IAAI,GAAG,IAAA,oBAAU,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CAAC,CAAC;IAC/D,IAAI,WAAW,EAAE;QACf,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;KACnC;IACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;YAC3C,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;aACR;YACD,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAlBD,sCAkBC"}

21
server/node_modules/koa-body/lib/utils/patch-util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import type { Context } from 'koa';
import type { Files } from 'formidable';
declare type PatchOptions = {
isMultipart: string | boolean | null;
isText: string | boolean | null;
includeUnparsed: boolean;
patchNode: boolean;
patchKoa: boolean;
};
export declare type ContextWithBodyAndFiles = Context & {
req: {
body?: any;
files?: Files;
};
request: {
body?: any;
files?: Files;
};
};
export declare function patchNodeAndKoa(ctx: ContextWithBodyAndFiles, body: any, options: PatchOptions): void;
export {};

42
server/node_modules/koa-body/lib/utils/patch-util.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.patchNodeAndKoa = void 0;
const unparsed_1 = __importDefault(require("../unparsed"));
function patchNodeAndKoa(ctx, body, options) {
const { patchKoa, patchNode, isMultipart, includeUnparsed, isText } = options;
if (patchNode) {
if (isMultipart) {
ctx.req.body = body.fields;
ctx.req.files = body.files;
}
else if (includeUnparsed) {
ctx.req.body = body.parsed || {};
if (!isText) {
ctx.req.body[unparsed_1.default] = body.raw;
}
}
else {
ctx.req.body = body;
}
}
if (patchKoa) {
if (isMultipart) {
ctx.request.body = body.fields;
ctx.request.files = body.files;
}
else if (includeUnparsed) {
ctx.request.body = body.parsed || {};
if (!isText) {
ctx.request.body[unparsed_1.default] = body.raw;
}
}
else {
ctx.request.body = body;
}
}
}
exports.patchNodeAndKoa = patchNodeAndKoa;
//# sourceMappingURL=patch-util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"patch-util.js","sourceRoot":"","sources":["../../src/ut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{ HttpMethodEnum } from '../types';
export default function toHttpMethod(method: string): HttpMethodEnum;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../types");
function toHttpMethod(method) {
return types_1.HttpMethodEnum[method];
}
exports.default = toHttpMethod;
//# sourceMappingURL=string-method-to-enum-method.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"string-method-to-enum-method.js","sourceRoot":"","sources":["../../src/utils/string-method-to-enum-method.ts"],"names":[],"mappings":";;AAAA,oCAA0C;AAE1C,SAAwB,YAAY,CAAC,MAAc;IACjD,OAAO,sBAAc,CAAC,MAAqC,CAAC,CAAC;AAC/D,CAAC;AAFD,+BAEC"}

View File

@@ -0,0 +1 @@
export default function throwableToError(e: unknown): Error;

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function throwableToError(e) {
if (e instanceof Error) {
return e;
}
const error = new Error(typeof e === 'object' ? JSON.stringify(e) : '' + e);
error.name = typeof e;
error.stack = undefined;
return error;
}
exports.default = throwableToError;
//# sourceMappingURL=throwable-to-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"throwable-to-error.js","sourceRoot":"","sources":["../../src/utils/throwable-to-error.ts"],"names":[],"mappings":";;AAAA,SAAwB,gBAAgB,CAAC,CAAU;IACjD,IAAI,CAAC,YAAY,KAAK,EAAE;QACtB,OAAO,CAAC,CAAC;KACV;IAED,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5E,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;IACtB,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;IAExB,OAAO,KAAK,CAAC;AACf,CAAC;AAVD,mCAUC"}

79
server/node_modules/koa-body/package.json generated vendored Normal file
View File

@@ -0,0 +1,79 @@
{
"name": "koa-body",
"version": "6.0.1",
"description": "A Koa body parser middleware. Supports multipart, urlencoded and JSON request bodies.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib",
"LICENSE",
"README.md",
"package.json"
],
"scripts": {
"build": "npm run check-format && npm run test && npm run clean && npm run build:typescript",
"build:typescript": "tsc --build tsconfig.build.json",
"clean": "rimraf lib",
"format": "prettier -w .",
"check-format": "prettier --check .",
"prepack": "npm run build",
"test": "mocha",
"examples-multer": "node examples/multer.js",
"examples-koa-router": "node examples/koa-router.js"
},
"author": {
"name": "Daryl Lau",
"email": "dlau00@gmail.com",
"url": "https://github.com/dlau"
},
"repository": {
"type": "git",
"url": "git://github.com/koajs/koa-body.git"
},
"keywords": [
"koa",
"urlencoded",
"multipart",
"json",
"body",
"parser",
"form"
],
"dependencies": {
"@types/co-body": "^6.1.0",
"@types/formidable": "^2.0.5",
"@types/koa": "^2.13.5",
"co-body": "^6.1.0",
"formidable": "^2.0.1",
"zod": "^3.19.1"
},
"devDependencies": {
"@types/koa-router": "^7.4.4",
"@types/mocha": "^10.0.0",
"@types/sinon": "^10.0.13",
"@types/supertest": "^2.0.12",
"koa": "^2.13.4",
"koa-router": "^12.0.0",
"mocha": "10.1.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"should": "13.2.3",
"sinon": "^14.0.1",
"supertest": "6.3.0",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
},
"contributors": [
{
"name": "Daryl Lau",
"email": "dlau00@gmail.com",
"url": "https://github.com/dlau"
},
{
"name": "Charlike Mike Reagent",
"email": "mameto_100@mail.bg",
"url": "https://github.com/tunnckoCore"
}
],
"license": "MIT"
}