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

54
server/node_modules/request-compose/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,54 @@
# Change Log
## v2.1.6 (2022/12/22)
- **Change:** Update deps and docs
## v2.1.5 (2022/06/03)
- **Fix:** Type definitions for TypeScript
## v2.1.4 (2021/05/09)
- **Fix:** Type definitions for TypeScript
## v2.1.3 (2021/03/20)
- **Fix:** Type definitions for TypeScript
## v2.1.2 (2021/03/20)
- **Fix:** Better support for JavaScript bundlers
## v2.1.1 (2021/03/14)
- **New:** Type definitions for TypeScript
## v2.1.0 (2020/06/06)
- **New:** Support for sync `request-logs`
- **Fix:** Append request path when redirecting to non root relative path
## v2.0.0 (2020/04/06)
- **Change:** Drop support for Node 4 and 6
## v1.2.3 (2020/03/22)
- **Fix:** Do not append original request querystring on redirect
## v1.2.2 (2020/03/01)
- **Fix:** Support for `request-multipart` middleware
## v1.2.1 (2019/08/28)
- **Fix:** The `proxy` option to set host header
## v1.2.0 (2019/01/22)
- **New:** Added `proxy` option
## v1.1.1 (2019/01/04)
- **Fix:** The `extend` method to always return a compose copy
## v1.1.0 (2018/12/14)
- **Change:** The `buffer` composition now decodes gzipped bodies
## v1.0.0 (2018/09/21)
- Public API Freeze
## v0.0.19 (2018/07/10)
- Last development release
## v0.0.1 (2018/01/30)
- Initial release

69
server/node_modules/request-compose/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,69 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright (c) 2018-present, Simeon Velichkov <simeonvelichkov@gmail.com> (https://github.com/simov/request-compose)
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

373
server/node_modules/request-compose/README.md generated vendored Normal file
View File

@@ -0,0 +1,373 @@
# request-compose
[![npm-version]][npm] [![test-ci-img]][test-ci-url] [![test-cov-img]][test-cov-url] [![snyk-vulnerabilities]][snyk]
> _Composable HTTP Client_
```js
var compose = require('request-compose')
var Request = compose.Request
var Response = compose.Response
;(async () => {
try {
var {res, body} = await compose(
Request.defaults({headers: {'user-agent': 'request-compose'}}),
Request.url('https://api.github.com/users/simov'),
Request.send(),
Response.buffer(),
Response.string(),
Response.parse(),
)()
console.log(res.statusCode, res.statusMessage)
console.log(res.headers['x-ratelimit-remaining'])
console.log(body)
}
catch (err) {
console.error(err)
}
})()
```
# Goals
- **No dependencies**
- **No abstraction**
- **No state**
# Table of Contents
- [**Compose**](#compose)
- [Bundled **Middlewares**](#bundled-middlewares)
- [Opinionated **Client**](#opinionated-client)
- [client](#client) / [buffer](#buffer) / [stream](#stream) / [options](#options) / [extend](#extend)
- [**Errors**](#errors)
- [Debug **Logs**](#debug-logs)
- [**Examples**](#examples)
# Compose
> In computer science, __[function composition][function-composition]__ (not to be confused with object composition) is an act or mechanism to combine simple functions to build more complicated ones. Like the usual composition of functions in mathematics, the result of each function is passed as the argument of the next, and the result of the last one is the result of the whole.
```js
var compose = require('request-compose')
```
Accepts a list of functions to execute and returns a [Promise]:
```js
var doit = compose(
(a) => a + 2,
(a) => a * 2,
)
```
Then we can call it:
```js
var result = await doit(5) // 14
```
A more practical example however would be to compose our own HTTP client:
```js
var compose = require('request-compose')
var https = require('https')
var request = compose(
(options) => {
options.headers = options.headers || {}
options.headers['user-agent'] = 'request-compose'
return options
},
(options) => new Promise((resolve, reject) => {
https.request(options)
.on('response', resolve)
.on('error', reject)
.end()
}),
async (res) => await new Promise((resolve, reject) => {
var body = ''
res
.on('data', (chunk) => body += chunk)
.on('end', () => resolve({res, body}))
.on('error', reject)
}),
({res, body}) => ({res, body: JSON.parse(body)}),
)
```
Then we can use it like this:
```js
;(async () => {
try {
var {res, body} = await request({
protocol: 'https:',
hostname: 'api.github.com',
path: '/users/simov',
})
console.log(res.statusCode, res.statusMessage)
console.log(res.headers['x-ratelimit-remaining'])
console.log(body)
}
catch (err) {
console.error(err)
}
})()
```
# Bundled Middlewares
`request-compose` comes with a bunch of pre-defined middlewares for transforming the [request][request-middlewares] and the [response][response-middlewares]:
```js
var compose = require('request-compose')
var Request = compose.Request
var Response = compose.Response
```
We can use these middlewares to compose our own HTTP client:
```js
;(async () => {
try {
var {res, body} = await compose(
Request.defaults({headers: {'user-agent': 'request-compose'}}),
Request.url('https://api.github.com/users/simov'),
Request.send(),
Response.buffer(),
Response.string(),
Response.parse(),
)()
console.log(res.statusCode, res.statusMessage)
console.log(res.headers['x-ratelimit-remaining'])
console.log(body)
}
catch (err) {
console.error(err)
}
})()
```
| Type | Middleware | Input | Arguments | Returns
| :--- | :--- | :--- | :--- | :---
| Request | defaults | {input} | {input} | {options}
| Request | url, proxy, qs, cookie | see [options](#options) | {options} | {options}
| Request | form, json, multipart, body | see [options](#options) | {options} | {options, body}
| Request | auth, oauth | see [options](#options) | {options, body} | {options, body}
| Request | length | - | {options, body} | {options, body}
| Request | send | - | {options, body} | {options, res}
| Response | buffer | - | {options, res} | {options, res, body}
| Response | gzip | - | {options, res, body, raw} | {options, res, body, raw}
| Response | string | see [options](#options) | {options, res, body, raw} | {options, res, body, raw}
| Response | parse, status | - | {options, res, body, raw} | {options, res, body, raw}
| Response | redirect | (input, client) | {options, res, body, raw} | new composition
# Opinionated Client
`request-compose` comes with opinionated HTTP client that is composed of the above [middlewares](#bundled-middlewares).
There are 3 types of composition available based on the returned data type:
## client
```js
var request = require('request-compose').client
var {res, body} = await request({options})
```
The `client` composition does the following:
- buffers the response body
- decompresses `gzip` and `deflate` encoded bodies with valid `content-encoding` header
- converts the response body to string using `utf8` encoding by default
- tries to parse `JSON` and `querystring` encoded bodies with valid `content-type` header
Returns either String or Object.
## buffer
```js
var request = require('request-compose').buffer
var {res, body} = await request({options})
```
The `buffer` composition does the following:
- buffers the response body
- decompresses `gzip` and `deflate` encoded bodies with valid `content-encoding` header
Returns [Buffer][buffer].
## stream
```js
var request = require('request-compose').stream
var {res} = await request({options})
```
The `stream` composition returns the response [Stream][stream-incoming-message].
## options
The above compositions accept any of the Node's [http.request][http-request] and [https.request][https-request] options:
```js
var {res, body} = await request({
method: 'GET',
url: 'https://api.github.com/users/simov',
headers: {
'user-agent': 'request-compose'
}
})
```
Additionally the following options are available:
| Option | Type | Description
| :-- | :-- | :--
| `url` | `'string'` [`url object`][url-parse] | URL _(encoding - see below)_
| `proxy` | `'string'` [`url object`][url-parse] | Proxy URL
| `qs` | `{object}` `'string'` | URL querystring _(encoding - see below)_
| `form` | `{object}` `'string'` | application/x-www-form-urlencoded request body _(encoding - see below)_
| `json` | `{object}` `'string'` | JSON encoded request body
| `multipart`| `{object}` `[array]` | multipart request body using [request-multipart], see [examples](#external-middlewares)
| `body` | `'string'` [`Buffer`][buffer] [`Stream`][stream-readable] | request body
| `auth` | `{user, pass}` | Basic authorization
| `oauth` | `{object}` | OAuth 1.0a authorization using [request-oauth], see [examples](#external-middlewares)
| `encoding` | [`'string'`][buffer-encoding] | response body encoding _(default: 'utf8')_
| `cookie` | `{object}` | cookie store using [request-cookie], see [examples](#external-middlewares)
| `redirect` | `{object}` | _see below_
> Querystring set in the `url`, and/or in `qs` and/or in `form` as _'string'_ is left untouched, meaning that the proper encoding is left to the user.
> When `qs` and/or `form` is _{object}_ the querystring is encoded using the Node's [querystring] module which mirrors the global [encodeURIComponent][encodeuri] method. Additionally all reserved characters according to RFC3986 are encoded as well. Full list of all reserved characters that are being encoded can be found [here][reserved-characters].
#### redirect
| Option | Default | Description
| :-- | :-- | :--
| `max` | *3* | maximum number of redirects to follow
| `all` | *false* | follow non-GET HTTP 3xx responses as redirects
| `method` | *true* | follow original HTTP method, otherwise convert all redirects to GET
| `auth` | *true* | keep Authorization header when changing hostnames
| `referer` | *false* | add Referer header
## extend
Extend or override any of the bundled [request][request-middlewares] and [response][response-middlewares] middlewares:
```js
var request = require('request-compose').extend({
Request: {
oauth: require('request-oauth'),
multipart: require('request-multipart'),
cookie: require('request-cookie').Request
},
Response: {cookie: require('request-cookie').Response},
}).client
```
# Errors
Non `200/300` responses are thrown as [Error] object with the following properties:
- `message` - status code + status message
- `res` - the response object
- `body` - the parsed response body
- `raw` - the raw response body
# Debug Logs
Fancy [request-logs]:
```bash
npm i --save-dev request-logs
```
Pick any of the following debug options:
```bash
DEBUG=req,res,body,json,nocolor node app.js
```
# Examples
| Topic | Example
| :-- | :--
| **`Basics`** |
| Types of lambda functions | [Get GitHub user profile](https://github.com/simov/request-compose/blob/master/examples/basic-lambda.js)
| Bundled middlewares | [Get GitHub user profile](https://github.com/simov/request-compose/blob/master/examples/basic-middlewares.js)
| Wrap it up and extend it | [Get GitHub user profile](https://github.com/simov/request-compose/blob/master/examples/basic-extend.js)
| **`Compositions`** |
| Client | [Get GitHub user profile](https://github.com/simov/request-compose/blob/master/examples/compose-client.js)
| Buffer | [Decoding response body using iconv-lite](https://github.com/simov/request-compose/blob/master/examples/compose-buffer.js)
| Stream | [Stream Tweets](https://github.com/simov/request-compose/blob/master/examples/compose-stream.js)
| **`External Middlewares`** |
| OAuth ([request-oauth]) | [Get Twitter User Profile](https://github.com/simov/request-compose/blob/master/examples/mw-oauth.js)
| Multipart ([request-multipart]) | [Upload photo to Twitter](https://github.com/simov/request-compose/blob/master/examples/mw-multipart.js)
| Cookie ([request-cookie]) | [Login to Wallhaven.cc](https://github.com/simov/request-compose/blob/master/examples/mw-cookie.js)
| **`Stream`** |
| Stream request body | [Upload file to Dropbox](https://github.com/simov/request-compose/blob/master/examples/stream-dropbox-upload.js)
| HTTP stream | [Upload image from Dropbox to Slack](https://github.com/simov/request-compose/blob/master/examples/stream-dropbox-to-slack.js)
| HTTP stream | [Copy file from Dropbox to GDrive](https://github.com/simov/request-compose/blob/master/examples/stream-dropbox-to-gdrive.js)
| **`Misc`** |
| Gzip decompression | [Request Gzip compressed body](https://github.com/simov/request-compose/blob/master/examples/misc-gzip.js)
| HTTPS proxy | [Tunnel Agent](https://github.com/simov/request-compose/blob/master/examples/misc-tunnel-agent.js)
| HTTPS proxy | [Proxy Agent](https://github.com/simov/request-compose/blob/master/examples/misc-proxy-agent.js)
| Override bundled middleware - per compose instance | [Override the `qs` middleware](https://github.com/simov/request-compose/blob/master/examples/misc-extend.js)
| Override bundled middleware - process-wide | [Override the `form` and the `parse` middlewares to use the `qs` module](https://github.com/simov/request-compose/blob/master/examples/misc-override.js)
| **`Pipeline`** |
| App pipeline | [Slack Weather Status](https://github.com/simov/request-compose/blob/master/examples/pipe-slack-weather-status.js)
| App pipeline | [Simultaneously search for repos in GitHub, GitLab and BitBucket](https://github.com/simov/request-compose/blob/master/examples/pipe-repo-search.js)
| **`Modules`** |
| Google Chrome Web Store HTTP Client | [chrome-webstore]
| REST API Client Library | [purest]
[npm-version]: https://img.shields.io/npm/v/request-compose.svg?style=flat-square (NPM Version)
[test-ci-img]: https://img.shields.io/github/actions/workflow/status/simov/request-compose/test.yml?style=flat-square (Build Status)
[test-cov-img]: https://img.shields.io/coveralls/simov/request-compose.svg?style=flat-square (Test Coverage)
[snyk-vulnerabilities]: https://img.shields.io/badge/vulnerabilities-0-geen?style=flat-square (Vulnerabilities)
[npm]: https://www.npmjs.com/package/request-compose
[test-ci-url]: https://github.com/simov/request-compose/actions/workflows/test.yml
[test-cov-url]: https://coveralls.io/r/simov/request-compose?branch=master
[snyk]: https://snyk.io/test/npm/request-compose
[function-composition]: https://en.wikipedia.org/wiki/Function_composition_(computer_science)
[pipeline]: https://en.wikipedia.org/wiki/Pipeline_(software)
[pipe-operator]: https://github.com/tc39/proposal-pipeline-operator
[chunked]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding
[request-middlewares]: https://github.com/simov/request-compose/tree/master/request
[response-middlewares]: https://github.com/simov/request-compose/tree/master/response
[request-oauth]: https://www.npmjs.com/package/request-oauth
[request-multipart]: https://www.npmjs.com/package/request-multipart
[request-cookie]: https://www.npmjs.com/package/request-cookie
[request-logs]: https://www.npmjs.com/package/request-logs
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
[error]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
[buffer]: https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html
[buffer-encoding]: https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html#buffer_buffers_and_character_encodings
[stream-readable]: https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_class_stream_readable
[stream-incoming-message]: https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_incomingmessage
[http-request]: https://nodejs.org/dist/latest-v14.x/docs/api/http.html#http_http_request_options_callback
[https-request]: https://nodejs.org/dist/latest-v14.x/docs/api/https.html#https_https_request_options_callback
[url-parse]: https://nodejs.org/dist/latest-v10.x/docs/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
[querystring-parse]: https://nodejs.org/dist/latest-v10.x/docs/api/querystring.html#querystring_querystring_parse_str_sep_eq_options
[querystring]: https://nodejs.org/dist/latest-v10.x/docs/api/querystring.html
[encodeuri]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
[reserved-characters]: https://en.wikipedia.org/wiki/Percent-encoding#Types_of_URI_characters
[chrome-webstore]: https://github.com/simov/chrome-webstore
[purest]: https://github.com/simov/purest

619
server/node_modules/request-compose/compose.d.ts generated vendored Normal file
View File

@@ -0,0 +1,619 @@
/// <reference types="node" />
import * as http from 'http'
import * as https from 'https'
import * as stream from 'stream'
// ----------------------------------------------------------------------------
/**
* Node core HTTP request options
* | [docs](https://nodejs.org/dist/latest-v14.x/docs/api/http.html#http_http_request_options_callback)
*/
interface NodeCoreHttpOptions {
/**
* Agent
*/
agent?: boolean | https.Agent | http.Agent
/**
* Basic authentication
*/
auth?: string
/**
* A function that produces a socket/stream to use for the request
*/
createConnection?: Function
/**
* Default port for the protocol
*/
defaultPort?: number
/**
* IP address family to use when resolving host or hostname
*/
family?: number
/**
* Request headers
*/
headers?: object
/**
* Hostname
*/
host?: string
/**
* Hostname
*/
hostname?: string
/**
* Use an insecure HTTP parser that accepts invalid HTTP headers
*/
insecureHTTPParser?: boolean
/**
* Local interface to bind for network connections
*/
localAddress?: string
/**
* Custom lookup function
*/
lookup?: Function
/**
* Maximum length of response headers in bytes
*/
maxHeaderSize?: number
/**
* HTTP request method
*/
method?: string
/**
* Request path
*/
path?: string
/**
* Port of remote server
*/
port?: number
/**
* Protocol to use
*/
protocol?: string
/**
* Specifies whether or not to automatically add the Host header
*/
setHost?: boolean
/**
* Unix Domain Socket
*/
socketPath?: string
/**
* Socket timeout in milliseconds
*/
timeout?: number
}
/**
* Node core HTTPS request options
* | [docs](https://nodejs.org/dist/latest-v14.x/docs/api/https.html#https_https_request_options_callback)
* | [docs](https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_connect_options_callback)
* | [docs](https://nodejs.org/dist/latest-v14.x/docs/api/tls.html#tls_tls_createsecurecontext_options)
*/
interface NodeCoreHttpsOptions {
/**
* Override the trusted CA certificates
*/
ca?: string | string[] | Buffer | Buffer[]
/**
* Cert chains in PEM format
*/
cert?: string | string[] | Buffer | Buffer[]
/**
* Cipher suite specification
*/
ciphers?: string
/**
* Name of an OpenSSL engine which can provide the client certificate
*/
clientCertEngine?: string
/**
* PEM formatted CRLs (Certificate Revocation Lists)
*/
crl?: string | string[] | Buffer | Buffer[]
/**
* Diffie-Hellman parameters
*/
dhparam?: string | Buffer
/**
* A string describing a named curve or a colon separated list of curve NIDs or names
*/
ecdhCurve?: string
/**
* Attempt to use the server's cipher suite preferences instead of the client's
*/
honorCipherOrder?: boolean
/**
* Private keys in PEM format
*/
key?: string | string[] | Buffer | Buffer[] | object[]
/**
* Shared passphrase used for a single private key and/or a PFX
*/
passphrase?: string
/**
* PFX or PKCS12 encoded private key and certificate chain
*/
pfx?: string | string[] | Buffer | Buffer[] | object[]
/**
* If not false a server automatically reject clients with invalid certificates
*/
rejectUnauthorized?: boolean
/**
* Optionally affect the OpenSSL protocol behavior
*/
secureOptions?: number
/**
* Legacy mechanism to select the TLS protocol version to use
*/
secureProtocol?: string
/**
* Server name for the SNI (Server Name Indication) TLS extension
*/
servername?: string
/**
* Opaque identifier used by servers to ensure session state is not shared between applications
*/
sessionIdContext?: string
/**
* Consistent with the readable stream highWaterMark parameter
*/
highWaterMark?: number
}
/**
* Request compose options
* | [docs](https://github.com/simov/request-compose#options)
*/
interface RequestComposeOptions {
/**
* Absolute URL
*/
url?: string
/**
* Proxy URL; for HTTPS use Agent instead
*/
proxy?: string
/**
* URL querystring
*/
qs?: object | string
/**
* application/x-www-form-urlencoded request body
*/
form?: object | string
/**
* JSON encoded request body
*/
json?: object | string
/**
* Raw request body
*/
body?: string | Buffer | stream.Readable
/**
* multipart/form-data as object or multipart/related as array
* | [docs](https://github.com/simov/request-multipart#request-multipart)
*/
multipart?: object | []
/**
* Basic authentication
*/
auth?: AuthOptions
/**
* OAuth 1.0a authentication
* | [docs](https://github.com/simov/request-oauth#request-oauth)
*/
oauth?: OAuthOptions
/**
* Response encoding
*/
encoding?: string
/**
* Cookie store
*/
cookie?: object
/**
* Redirect options
*/
redirect?: RedirectOptions
}
/**
* Request compose default options
*/
interface RequestComposeDefaults {
/**
* Request headers
* @default {}
*/
headers?: object
/**
* Hostname
* @default localhost
*/
hostname?: string
/**
* HTTP request method
* @default 'GET'
*/
method?: string
/**
* Request path
* @default '/'
*/
path?: string
/**
* Port of remote server
* @default 80
*/
port?: number
/**
* Protocol to use
* @default 'http:'
*/
protocol?: string
/**
* Socket timeout in milliseconds
* @default 3000
*/
timeout?: number
}
/**
* Basic authentication
*/
export interface AuthOptions {
/**
* User name
*/
user?: string
/**
* Password
*/
pass?: string
}
/**
* OAuth 1.0a
* | [docs](https://github.com/simov/request-oauth#options)
*/
export interface OAuthOptions {
/**
* Consumer key
*/
consumer_key: string
/**
* Consumer secret
*/
consumer_secret?: string
/**
* Private key
*/
private_key?: string
/**
* Access token
*/
token: string
/**
* Access secret
*/
token_secret: string
/**
* OAuth version
* @default 1.0
*/
version?: string
/**
* Signature method
* @default HMAC-SHA1
*/
signature_method?: 'HMAC-SHA1' | 'RSA-SHA1' | 'PLAINTEXT'
/**
* Transport method
* @default header
*/
transport_method?: 'header' | 'query' | 'form'
/**
* Timestamp
*/
timestamp?: string
/**
* Nonce
*/
nonce?: string
/**
* Realm
*/
realm?: string
/**
* Body hash string or true to generate one
*/
body_hash?: string | boolean
}
/**
* Redirect options
* | [docs](https://github.com/simov/request-compose#redirect)
*/
export interface RedirectOptions {
/**
* Maximum number of redirects to follow
* @default 3
*/
max?: number
/**
* Follow non-GET HTTP 3xx responses as redirects
* @default false
*/
all?: boolean
/**
* Follow original HTTP method, otherwise convert all redirects to GET
* @default true
*/
method?: boolean
/**
* Keep authorization header when changing hostnames
* @default true
*/
auth?: boolean
/**
* Add referer header
* @default false
*/
referer?: boolean
}
/**
* Node core request options
*/
type NodeCoreRequestOptions = NodeCoreHttpOptions & NodeCoreHttpsOptions
/**
* Request options
* | [docs](https://github.com/simov/request-compose#options)
*/
export type RequestOptions = NodeCoreRequestOptions & RequestComposeOptions & RequestComposeDefaults
// ----------------------------------------------------------------------------
/**
* Request compose default options
*/
type RequestMiddlewareDefaults = NodeCoreRequestOptions & Required<RequestComposeDefaults>
/**
* Request middleware options
*/
interface RequestMiddlewareOptions {
/**
* Node core request options
*/
options: RequestMiddlewareDefaults
/**
* Request body
*/
body?: string | object | Buffer | stream.Readable
}
/**
* Response middleware options
*/
interface ResponseMiddlewareOptions {
/**
* Node core request options
*/
options: RequestMiddlewareDefaults
/**
* Response object
*/
res: http.IncomingMessage
/**
* Response body
*/
body?: string | object | Buffer
/**
* Raw response body
*/
raw?: Buffer | string
}
/**
* Defaults middleware
*/
export type DefaultsMiddleware = (options?: any) => () => RequestMiddlewareOptions
/**
* Request middleware
*/
export type RequestMiddleware = (options?: any) => (options: RequestMiddlewareOptions) => RequestMiddlewareOptions
/**
* Response middleware
*/
export type ResponseMiddleware = (options?: any) => (options: ResponseMiddlewareOptions) => ResponseMiddlewareOptions
/**
* Request middlewares
*/
interface RequestMiddlewares {
/**
* Request defaults
*/
defaults: DefaultsMiddleware
/**
* Absolute URL
*/
url: RequestMiddleware
/**
* Proxy URL
*/
proxy: RequestMiddleware
/**
* URL querystring
*/
qs: RequestMiddleware
/**
* Cookie store
*/
cookie?: RequestMiddleware
/**
* application/x-www-form-urlencoded request body
*/
form: RequestMiddleware
/**
* JSON encoded request body
*/
json: RequestMiddleware
/**
* Multipart encoded request body
*/
multipart?: RequestMiddleware
/**
* Raw request body
*/
body: RequestMiddleware
/**
* Basic authentication
*/
auth: RequestMiddleware
/**
* OAuth 1.0a
*/
oauth?: RequestMiddleware
/**
* Request body length
*/
length: RequestMiddleware
/**
* Request
*/
send: RequestMiddleware
}
/**
* Response middlewares
*/
interface ResponseMiddlewares {
/**
* Buffer response body
*/
buffer: ResponseMiddleware
/**
* Decode gzip/deflate encoded response body
*/
gzip: ResponseMiddleware
/**
* String response body
*/
string: ResponseMiddleware
/**
* Parse JSON or application/x-www-form-urlencoded encoded response body
*/
parse: ResponseMiddleware
/**
* Throw on non successful status codes
*/
status: ResponseMiddleware
/**
* HTTP redirect
*/
redirect: ResponseMiddleware
}
/**
* Extend middlewares
*/
interface ExtendMiddlewares {
/**
* Request middlewares
*/
Request?: Partial<RequestMiddlewares>
/**
* Response middlewares
*/
Response?: Partial<ResponseMiddlewares>
}
// ----------------------------------------------------------------------------
/**
* Client response
*/
export interface ClientResponse {
/**
* Response object
*/
res: http.IncomingMessage
/**
* Response body
*/
body: string | object
}
/**
* Buffer response
*/
export interface BufferResponse {
/**
* Response object
*/
res: http.IncomingMessage
/**
* Response body
*/
body: Buffer
}
/**
* Stream response
*/
export interface StreamResponse {
/**
* Response object
*/
res: http.IncomingMessage
}
// ----------------------------------------------------------------------------
/**
* Functional composition
*/
declare function compose(...functions: any): (options?: any) => Promise<any>
/**
* Functional composition
*/
declare namespace compose {
/**
* Request middlewares
*/
const Request: RequestMiddlewares
/**
* Response middlewares
*/
const Response: ResponseMiddlewares
/**
* Client composition
*/
function client(options: RequestOptions): Promise<ClientResponse>
/**
* Buffer composition
*/
function buffer(options: RequestOptions): Promise<BufferResponse>
/**
* Stream composition
*/
function stream(options: RequestOptions): Promise<StreamResponse>
/**
* Extend instance
*/
function extend(options: ExtendMiddlewares): typeof compose
}
export default compose

142
server/node_modules/request-compose/compose.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
var ctor = () => (...fns) => (args) =>
fns.reduce((p, f) => p.then(f), Promise.resolve(args))
var compose = ctor()
var Request = {
defaults: require('./request/defaults'),
url: require('./request/url'),
proxy: require('./request/proxy'),
qs: require('./request/qs'),
form: require('./request/form'),
json: require('./request/json'),
body: require('./request/body'),
auth: require('./request/auth'),
length: require('./request/length'),
send: require('./request/send'),
}
var Response = {
buffer: require('./response/buffer'),
gzip: require('./response/gzip'),
string: require('./response/string'),
parse: require('./response/parse'),
status: require('./response/status'),
redirect: require('./response/redirect'),
}
var request = (Request) => (args) => compose(
Request.defaults(args),
(() =>
args.url ? Request.url(args.url) : ({options}) => ({options})
)(),
(() =>
args.proxy ? Request.proxy(args.proxy) : ({options}) => ({options})
)(),
(() =>
args.qs ? Request.qs(args.qs, args.redirect) : ({options}) => ({options})
)(),
(() =>
args.cookie ? Request.cookie(args.cookie) : ({options}) => ({options})
)(),
(() =>
args.form ? Request.form(args.form) :
args.json ? Request.json(args.json) :
args.multipart ? Request.multipart(args.multipart) :
args.body ? Request.body(args.body) :
({options}) => ({options})
)(),
(() =>
args.auth ? Request.auth(args.auth) :
args.oauth ? Request.oauth(args.oauth) :
({options, body}) => ({options, body})
)(),
(() => ({options, body}) =>
body ? Request.length()({options, body}) : {options}
)(),
Request.send(),
)()
var client = (Request, Response) => (args) => compose(
_ => request(Request)(args),
(() =>
args.cookie ? Response.cookie(args.cookie) :
({options, res}) => ({options, res})
)(),
Response.buffer(),
Response.gzip(),
Response.string(args.encoding),
Response.parse(),
Response.status(),
Response.redirect(args, client(Request, Response)),
)()
var buffer = (Request, Response) => (args) => compose(
_ => request(Request)(args),
(() =>
args.cookie ? Response.cookie(args.cookie) :
({options, res}) => ({options, res})
)(),
Response.buffer(),
Response.gzip(),
Response.status(),
Response.redirect(args, buffer(Request, Response)),
)()
var stream = (Request, Response) => (args) => compose(
_ => request(Request)(args),
(() =>
args.cookie ? Response.cookie(args.cookie) :
({options, res}) => ({options, res})
)(),
Response.status(),
// TODO: should buffer the read chunks and re-write them
// Response.redirect(args, stream),
)()
var extend = (mw) => ((
req = Object.assign({}, Request, mw.Request),
res = Object.assign({}, Response, mw.Response),
) =>
Object.assign(ctor(), {
Request: req,
Response: res,
client: client(req, res),
buffer: buffer(req, res),
stream: stream(req, res),
extend,
})
)()
module.exports = extend({Request, Response})

52
server/node_modules/request-compose/package.json generated vendored Normal file
View File

@@ -0,0 +1,52 @@
{
"name": "request-compose",
"version": "2.1.7",
"description": "Composable HTTP Client",
"keywords": [
"functional",
"compose",
"composable",
"http",
"client"
],
"license": "Apache-2.0",
"homepage": "https://github.com/simov/request-compose",
"author": "Simeon Velichkov <simeonvelichkov@gmail.com> (https://simov.github.io)",
"repository": {
"type": "git",
"url": "https://github.com/simov/request-compose.git"
},
"dependencies": {},
"devDependencies": {
"mocha": "^10.7.3",
"nyc": "^17.0.0",
"qs": "^6.13.0",
"request-cookie": "^1.0.0",
"request-logs": "^2.1.5",
"request-multipart": "^1.0.0",
"request-oauth": "^1.0.1"
},
"main": "./compose.js",
"type": "commonjs",
"files": [
"request/",
"response/",
"utils/",
"compose.js",
"compose.d.ts",
"index.js",
"CHANGELOG.md",
"LICENSE",
"README.md",
"package.json"
],
"types": "compose.d.ts",
"scripts": {
"test": "npm run test:ci",
"test:ci": "npx mocha --recursive",
"test:cov": "npx nyc --reporter=lcov --reporter=text-summary mocha -- --recursive"
},
"engines": {
"node": ">=12.0.0"
}
}

11
server/node_modules/request-compose/request/auth.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
module.exports = (auth) => ({options, options: {headers}, body}) => {
if (typeof auth === 'object') {
headers.Authorization =
`Basic ${Buffer.from(`${auth.user}:${auth.pass || ''}`, 'utf8').toString('base64')}`
delete options.auth
}
return {options, body}
}

4
server/node_modules/request-compose/request/body.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
module.exports = (body) => ({options}) => {
return {options, body}
}

View File

@@ -0,0 +1,64 @@
var options = [
// https://nodejs.org/dist/latest-v14.x/docs/api/http.html#http_http_request_options_callback
'agent',
'auth',
'createConnection',
'defaultPort',
'family',
'headers',
'host',
'hostname',
'insecureHTTPParser',
'localAddress',
'lookup',
'maxHeaderSize',
'method',
'path',
'port',
'protocol',
'setHost',
'socketPath',
'timeout',
// https://nodejs.org/dist/latest-v14.x/docs/api/https.html#https_https_request_options_callback
'ca',
'cert',
'ciphers',
'clientCertEngine',
'crl',
'dhparam',
'ecdhCurve',
'honorCipherOrder',
'key',
'passphrase',
'pfx',
'rejectUnauthorized',
'secureOptions',
'secureProtocol',
'servername',
'sessionIdContext',
'highWaterMark',
]
module.exports = (_args = {}) => (args = _args) => {
var defaults = {
protocol: args.protocol || 'http:',
hostname: args.hostname || 'localhost',
port: args.port || 80,
method: (args.method || 'GET').toUpperCase(),
path: args.path || '/',
headers: args.headers ? JSON.parse(JSON.stringify(args.headers)) : {},
timeout: args.timeout || 5000,
}
return {
options: options.reduce((http, option) => (
defaults[option] !== undefined ? http[option] = defaults[option] :
args[option] !== undefined ? http[option] = args[option] :
null,
http
), {})
}
}

25
server/node_modules/request-compose/request/form.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var querystring = require('querystring')
module.exports = (form) => ({options, options: {headers}}) => {
var header = Object.keys(headers)
.find((name) => name.toLowerCase() === 'content-type')
if (!header) {
headers['content-type'] = 'application/x-www-form-urlencoded'
}
var body =
typeof form === 'string'
? form :
typeof form === 'object'
? rfc3986(querystring.stringify(JSON.parse(JSON.stringify(form)))) :
''
return {options, body}
}
var rfc3986 = (str) => str.replace(
/[!'()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase())

14
server/node_modules/request-compose/request/json.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
module.exports = (json) => ({options, options: {headers}}) => {
json = typeof json === 'object' ? JSON.stringify(json) : (json || '')
var header = Object.keys(headers)
.find((name) => name.toLowerCase() === 'content-type')
if (!header) {
headers['content-type'] = 'application/json'
}
return {options, body: json}
}

78
server/node_modules/request-compose/request/length.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
var fs = require('fs')
var stream = require('stream')
module.exports = () => ({options, options: {headers}, body}) => new Promise((resolve) =>{
var length = Object.keys(headers)
.find((name) => name.toLowerCase() === 'content-length')
var encoding = Object.keys(headers)
.find((name) => name.toLowerCase() === 'transfer-encoding')
if (headers[length] || headers[encoding] === 'chunked') {
resolve({options, body})
return
}
var getLength = (body, length, done) => {
if (typeof body === 'string') {
done(null, Buffer.byteLength(body))
}
else if (body instanceof Buffer) {
done(null, body.length)
}
// request-multipart
else if (body && body.constructor && body.constructor.name === 'BufferListStream') {
done(null, body.length)
}
else if (body instanceof stream.Stream) {
// fs.ReadStream
if (body.hasOwnProperty('fd')) {
fs.stat(body.path, (err, stats) => done(err, stats && stats.size))
}
// http.IncomingMessage
else if (body.hasOwnProperty('httpVersion')) {
done(!body.headers['content-length'], parseInt(body.headers['content-length']))
}
// request-multipart
else if (body._items) {
;(function loop (index) {
if (index === body._items.length) {
done(null, length)
return
}
var item = body._items[index]
if (item._knownLength) {
length += parseInt(item._knownLength)
loop(++index)
}
else {
getLength(item, length, (err, len) => {
if (err) {
done(err)
return
}
length += len
loop(++index)
})
}
})(0)
}
else {
done(true)
}
}
else {
done(true)
}
}
getLength(body, 0, (err, length) => {
err
? headers['transfer-encoding'] = 'chunked'
: headers['content-length'] = length
resolve({options, body})
})
})

24
server/node_modules/request-compose/request/proxy.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
var url = require('url')
module.exports = (proxy) => ({options}) => {
options.path = (() => {
var path = `${options.protocol}//${options.hostname}`
if (options.port && !/^(?:80|443)$/.test(options.port)) {
path += `:${options.port}`
}
path += options.path
return path
})()
options.headers.host = options.hostname
var uri = typeof proxy === 'string' ? url.parse(proxy) : proxy
options.protocol = uri.protocol
options.hostname = uri.hostname
options.port = uri.port
return {options}
}

28
server/node_modules/request-compose/request/qs.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
var querystring = require('querystring')
module.exports = (qs, redirect = {}) => ({options}) => {
if (redirect.followed) {
return {options}
}
if (typeof qs === 'object') {
qs = JSON.parse(JSON.stringify(qs))
var [path, query] = options.path.split('?')
query = querystring.parse(query)
qs = rfc3986(querystring.stringify(Object.assign(query, qs)))
options.path = path + (qs ? `?${qs}` : '')
}
else if (typeof qs === 'string') {
var [path, query] = options.path.split('?')
options.path = path + (query ? `?${query}&${qs}` : `?${qs}`)
}
return {options}
}
var rfc3986 = (str) => str.replace(
/[!'()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase())

37
server/node_modules/request-compose/request/send.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var http = require('http')
var https = require('https')
var stream = require('stream')
var crypto = require('crypto')
var log = require('../utils/log')
module.exports = () => ({options, body}) => new Promise((resolve, reject) => {
var id = crypto.randomBytes(20).toString('hex')
var req =
(/https/.test(options.protocol) ? https : http)
.request(options)
.on('response', (res) => {
res.id = id
log({send: {res}})
resolve({options, res})
})
.on('error', reject)
.on('timeout', () => {
var err = new Error('request-compose: timeout')
err.code = 'ETIMEDOUT'
req.emit('error', err)
req.abort()
})
.setTimeout(options.timeout)
;(body instanceof stream.Stream)
? body.pipe(req)
: req.end(body)
req.id = id
log({send: {req, body, options}})
})

15
server/node_modules/request-compose/request/url.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
var url = require('url')
module.exports = (uri) => ({options}) => {
uri = typeof uri === 'string' ? url.parse(uri) : uri
options.protocol = uri.protocol
options.hostname = uri.hostname
options.port = uri.port
options.path = uri.path
return {options}
}

11
server/node_modules/request-compose/response/buffer.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
module.exports = () => ({options, res}) => new Promise((resolve, reject) => {
var body = []
res
.on('data', (chunk) => body.push(chunk))
.on('end', () => {
body = Buffer.concat(body)
resolve({options, res, body})
})
.on('error', reject)
})

34
server/node_modules/request-compose/response/gzip.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
var zlib = require('zlib')
module.exports = () => ({options, res, body, raw}) => new Promise((resolve, reject) => {
var header = Object.keys(res.headers)
.find((name) => name.toLowerCase() === 'content-encoding')
var decode =
/gzip/i.test(res.headers[header]) ? 'gunzip' :
/deflate/i.test(res.headers[header]) ? 'inflate' :
false
if (decode) {
raw = body
var opts = {
flush: zlib.Z_SYNC_FLUSH,
finishFlush: zlib.Z_SYNC_FLUSH,
}
zlib[decode](body, opts, (err, decoded) => {
if (err) {
reject(err)
return
}
resolve({options, res, body: decoded, raw})
})
}
else {
resolve({options, res, body, raw})
}
})

31
server/node_modules/request-compose/response/parse.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
var querystring = require('querystring')
var log = require('../utils/log')
module.exports = () => ({options, res, res: {headers}, body, raw}) => {
raw = body
var header = Object.keys(headers)
.find((name) => name.toLowerCase() === 'content-type')
if (/json|javascript/.test(headers[header])) {
try {
body = JSON.parse(body)
}
catch (err) {}
}
else if (/application\/x-www-form-urlencoded/.test(headers[header])) {
try {
body = querystring.parse(body)
}
catch (err) {}
}
log({parse: {res, body}})
return {options, res, body, raw}
}

View File

@@ -0,0 +1,86 @@
var url = require('url')
var error = require('../utils/error')
module.exports = (args, client) => ({options, res, body, raw}) => {
if (!/^3/.test(res.statusCode)) {
// not a redirect
return {options, res, body, raw}
}
var defaults = {
max: 3,
all: false,
method: true,
referer: false,
auth: true,
followed: 0,
hostname: options.hostname,
}
var redirect = Object.assign(defaults, args.redirect)
var header = Object.keys(res.headers)
.find((name) => name.toLowerCase() === 'location')
var location = res.headers[header]
if (!location || (!redirect.all && /patch|put|post|delete/i.test(options.method))) {
// do not follow redirects
return {options, res, body, raw}
}
// relative location
if (!/^https?:/.test(location)) {
location = url.resolve(
options.protocol + '//' + options.hostname +
(options.port && options.port !== 80 ? `:${options.port}` : ''),
location.startsWith('/')
? location
: (options.path + `/${location}`).replace(/\/{2,}/g, '/')
)
}
// args
var copy = Object.assign({}, args, {url: location, redirect})
copy.headers = JSON.parse(JSON.stringify(copy.headers || {}))
// remove authorization
if (!redirect.auth && redirect.hostname !== url.parse(location).hostname) {
var header = Object.keys(copy.headers)
.find((name) => name.toLowerCase() === 'authorization')
if (header) {
delete copy.headers[header]
}
delete copy.auth
delete copy.oauth
}
// switch to safe method
if (!redirect.method && /patch|put|post|delete/i.test(options.method)) {
copy.method = 'GET'
}
// set referer
if (redirect.referer) {
copy.headers.referer = url.resolve(
options.protocol + '//' + options.hostname +
(options.port && options.port !== 80 ? `:${options.port}` : ''),
options.path
)
}
// redirect
if (redirect.followed < redirect.max) {
redirect.followed++
return client(copy)
}
else {
var err = error({res, body, raw})
err.message = 'request-compose: exceeded maximum redirects'
throw err
}
}

17
server/node_modules/request-compose/response/status.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
var error = require('../utils/error')
var log = require('../utils/log')
module.exports = () => ({options, res, body, raw}) => {
log({status: {res, body, raw}})
if (/^(2|3)/.test(res.statusCode)) {
return {options, res, body, raw}
}
else if (/^(4|5)/.test(res.statusCode)) {
throw error({options, res, body, raw})
}
}

15
server/node_modules/request-compose/response/string.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
var log = require('../utils/log')
module.exports = (encoding) => ({options, res, body, raw}) => {
raw = body
body = Buffer.from(body).toString(encoding)
log({string: {res, body}})
return {options, res, body, raw}
}

12
server/node_modules/request-compose/utils/error.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
module.exports = ({res, body, raw = body}) => {
var error = new Error()
error.message = `${res.statusCode} ${res.statusMessage}`
error.res = res
error.body = body
error.raw = raw
return error
}

9
server/node_modules/request-compose/utils/log.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
module.exports = (data) => {
if (process.env.DEBUG) {
try {
require('request-logs')(data)
}
catch (err) {}
}
}