Comparing version 3.1.3 to 3.1.4
@@ -1,2 +0,2 @@ | ||
let aqt = require('@rqt/aqt'); if (aqt && aqt.__esModule) aqt = aqt.default; | ||
const aqt = require('@rqt/aqt'); | ||
@@ -9,3 +9,3 @@ /** | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -15,3 +15,3 @@ * @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
const rqt = async (address, options = {}) => { | ||
const rqt = async (address, options = {}) => { | ||
const { body } = await aqt(address, options) | ||
@@ -29,3 +29,3 @@ /** @type {string} */ | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -35,3 +35,3 @@ * @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
const jqt = async (address, options = {}) => { | ||
const jqt = async (address, options = {}) => { | ||
const { body } = await aqt(address, options) | ||
@@ -49,3 +49,3 @@ /** @type {*} */ | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -55,3 +55,3 @@ * @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
const bqt = async (address, options) => { | ||
const bqt = async (address, options) => { | ||
const c = { | ||
@@ -73,3 +73,3 @@ ...options, | ||
* @param {'form'|'json'} [config.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [config.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [config.headers] Headers to use for the request. | ||
* @param {boolean} [config.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -79,3 +79,3 @@ * @param {string} [config.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
const srqt = async (address, config) => { | ||
const srqt = async (address, config) => { | ||
throw new Error('not implemented') | ||
@@ -89,8 +89,7 @@ // config.binary = true | ||
/** | ||
* @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders | ||
* | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} Options Options for requests. | ||
* @prop {*} [data] Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {http.OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -100,2 +99,6 @@ * @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
@@ -102,0 +105,0 @@ |
@@ -1,2 +0,2 @@ | ||
let aqt = require('@rqt/aqt'); if (aqt && aqt.__esModule) aqt = aqt.default; | ||
const aqt = require('@rqt/aqt'); | ||
@@ -6,8 +6,8 @@ /** | ||
*/ | ||
class Session { | ||
class Session { | ||
/** | ||
* Create a new session that can be used to make requests in sequence, and remember cookies. | ||
* @param {SessionOptions} options Options for a session. | ||
* @param {string} [options.host] The prefix to each request, such as `https://rqt.biz`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for each request. | ||
* @param {string} [options.host] The prefix to each request, such as `https://rqt.biz`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for each request. | ||
*/ | ||
@@ -28,8 +28,8 @@ constructor(options = {}) { | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
*/ | ||
@@ -46,8 +46,8 @@ async rqt(location, options = {}) { | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
*/ | ||
@@ -67,8 +67,8 @@ async bqt(location, options = {}) { | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
*/ | ||
@@ -142,4 +142,4 @@ async jqt(location, options = {}) { | ||
/** | ||
* @param {Object} cookies | ||
* @param {import('http').IncomingHttpHeaders} headers | ||
* @param {!Object} cookies | ||
* @param {http.IncomingHttpHeaders} headers | ||
*/ | ||
@@ -181,10 +181,9 @@ const updateCookies = (cookies, headers) => { | ||
/* documentary types/options.xml */ | ||
/* typal types/options.xml */ | ||
/** | ||
* @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders | ||
* | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} Options Options for requests. | ||
* @prop {*} [data] Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {http.OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -194,5 +193,10 @@ * @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
/* documentary types/session.xml */ | ||
/* typal types/session.xml */ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} SessionOptions Options for a session. | ||
@@ -203,10 +207,13 @@ * @prop {string} [host] The prefix to each request, such as `https://rqt.biz`. | ||
/* documentary node_modules/@rqt/aqt/types/index.xml */ | ||
/* typal node_modules/@rqt/aqt/types/index.xml */ | ||
/** | ||
* @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders | ||
* | ||
* @typedef {Object} AqtOptions Configuration for requests. | ||
* @prop {Object} data Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {_rqt.AqtOptions} AqtOptions Configuration for requests. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} _rqt.AqtOptions Configuration for requests. | ||
* @prop {!Object} [data] Optional data to send to the server with the request. | ||
* @prop {string} [type="json"] How to send data: `json` to serialise JSON data and add _Content-Type: application/json_ header, and `form` for url-encoded transmission with _Content-Type: application/x-www-form-urlencoded_. _Multipart/form-data_ must be implemented manually. Default `json`. | ||
* @prop {!http.OutgoingHttpHeaders} [headers] Headers to use for the request. By default, a single User-Agent header with _Mozilla/5.0 (Node.JS) aqt/{version}_ value is set. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -218,4 +225,12 @@ * @prop {number} [timeout] The timeout after which the request should fail. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').IncomingHttpHeaders} http.IncomingHttpHeaders | ||
*/ | ||
module.exports = Session |
@@ -0,1 +1,7 @@ | ||
## 29 July 2019 | ||
### [3.1.4](https://github.com/rqt/rqt/compare/v3.1.3...v3.1.4) | ||
- [deps] Upgrade to compiled `aqt`. | ||
## 16 April 2019 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "rqt", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "Easy-To-Use Request Library That Supports String, JSON And Buffer Requests, Timeouts, GZip Compression And Session Maintenance.", | ||
@@ -11,7 +11,5 @@ "main": "build", | ||
"test-build": "ALAMODE_ENV=test-build yarn test", | ||
"doc": "NODE_DEBUG=doc doc documentary -o README.md", | ||
"d1": "NODE_DEBUG=doc doc src/index.js -g", | ||
"d2": "NODE_DEBUG=doc doc src/lib/index.js -g", | ||
"d3": "NODE_DEBUG=doc doc src/lib/Session.js -g", | ||
"d": "yarn-s d1 d2 d3", | ||
"doc": "NODE_DEBUG=doc doc -o README.md -n _rqt", | ||
"d1": "typal src/index.js src/lib/index.js src/lib/Session.js -c", | ||
"d": "yarn-s d1", | ||
"lint": "eslint .", | ||
@@ -50,14 +48,14 @@ "b": "alamode src -o build -s", | ||
"devDependencies": { | ||
"@idio/core": "^1.3.6", | ||
"@idio/idio": "^0.1.0", | ||
"@wrote/read": "^1.0.4", | ||
"alamode": "^1.9.3", | ||
"documentary": "^1.23.4", | ||
"alamode": "^2.3.6", | ||
"documentary": "^1.28.0", | ||
"eslint-config-artdeco": "1.0.1", | ||
"https-context": "^1.0.3", | ||
"yarn-s": "1.1.0", | ||
"zoroaster": "^3.11.5" | ||
"zoroaster": "^4.1.1-alpha" | ||
}, | ||
"dependencies": { | ||
"@rqt/aqt": "^1.2.5" | ||
"@rqt/aqt": "^1.3.0" | ||
} | ||
} |
169
README.md
@@ -27,3 +27,3 @@ # rqt | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/0.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/0.svg?sanitize=true"></a></p> | ||
@@ -46,3 +46,3 @@ ## API | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/1.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/1.svg?sanitize=true"></a></p> | ||
@@ -55,16 +55,16 @@ | ||
`import('http').OutgoingHttpHeaders` __<a name="type-httpoutgoinghttpheaders">`http.OutgoingHttpHeaders`</a>__ | ||
[`import('http').OutgoingHttpHeaders`](https://nodejs.org/api/http.html#http_class_http_outgoinghttpheaders) __<a name="type-httpoutgoinghttpheaders">`http.OutgoingHttpHeaders`</a>__: The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc. | ||
__<a name="type-options">`Options`</a>__: Options for requests. | ||
| Name | Type | Description | Default | | ||
| -------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | | ||
| data | _*_ | Optional data to send to the server with the request. | - | | ||
| type | _'form' \| 'json'_ | How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. | `'json'` | | ||
| headers | _[http.OutgoingHttpHeaders](#type-httpoutgoinghttpheaders)_ | Headers to use for the request. | - | | ||
| compress | _boolean_ | Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. | `true` | | ||
| method | _string_ | What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | - | | ||
| timeout | _number_ | Timeout after which the request should cancel. | - | | ||
| Name | Type | Description | Default | | ||
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | | ||
| data | <em>*</em> | Optional data to send to the server with the request. | - | | ||
| type | <em>('form' \| 'json')</em> | How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. | `'json'` | | ||
| headers | <em><a href="#type-httpoutgoinghttpheaders" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">http.OutgoingHttpHeaders</a></em> | Headers to use for the request. | - | | ||
| compress | <em>boolean</em> | Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. | `true` | | ||
| method | <em>string</em> | What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | - | | ||
| timeout | <em>number</em> | Timeout after which the request should cancel. | - | | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/2.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/2.svg?sanitize=true"></a></p> | ||
@@ -91,10 +91,8 @@ ## `async rqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): string` | ||
```js | ||
import idioCore from '@idio/core' | ||
import idioCore from '@idio/idio' | ||
const Server = async () => { | ||
const { url } = await idioCore({ | ||
/** @type {import('koa').Middleware} */ | ||
async hello(ctx, next) { | ||
async hello(ctx) { | ||
ctx.body = 'Hello World' | ||
await next() | ||
}, | ||
@@ -151,9 +149,14 @@ }, { port: 0 }) | ||
```js | ||
import idioCore from '@idio/core' | ||
import idioCore from '@idio/idio' | ||
import { collect } from 'catchment' | ||
import { parse } from 'querystring' | ||
const Server = async () => { | ||
const { url } = await idioCore({ | ||
bodyparser: { use: true }, | ||
/** @type {import('koa').Middleware} */ | ||
async test(ctx, next) { | ||
async bodyparser(ctx, next) { | ||
const data = await collect(ctx.req) | ||
if (data) ctx.request.body = parse(data) | ||
await next() | ||
}, | ||
test(ctx) { | ||
ctx.body = `You have requested with ${ctx.method}: | ||
@@ -163,3 +166,2 @@ Body: ${JSON.stringify(ctx.request.body, null, 2)} | ||
` | ||
await next() | ||
}, | ||
@@ -174,3 +176,3 @@ }, { port: 5001 }) | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/3.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/3.svg?sanitize=true"></a></p> | ||
@@ -195,3 +197,3 @@ ## `async jqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): Object` | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/4.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/4.svg?sanitize=true"></a></p> | ||
@@ -214,3 +216,3 @@ ## `async bqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): Buffer` | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/5.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/5.svg?sanitize=true"></a></p> | ||
@@ -221,29 +223,27 @@ ## `async aqt(`<br/> `url: string,`<br/> `options?: AqtOptions,`<br/>`): AqtReturn` | ||
`import('http').OutgoingHttpHeaders` __<a name="type-httpoutgoinghttpheaders">`http.OutgoingHttpHeaders`</a>__ | ||
__<a name="type-aqtoptions">`AqtOptions`</a>__: Configuration for requests. | ||
| Name | Type | Description | Default | | ||
| ----------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | | ||
| __data*__ | _Object_ | Optional data to send to the server with the request. | - | | ||
| type | _'form' \| 'json'_ | How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. | `'json'` | | ||
| headers | _[http.OutgoingHttpHeaders](#type-httpoutgoinghttpheaders)_ | Headers to use for the request. | - | | ||
| compress | _boolean_ | Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. | `true` | | ||
| timeout | _number_ | The timeout after which the request should fail. | - | | ||
| method | _string_ | What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | - | | ||
| binary | _boolean_ | Whether to return a buffer instead of a string. | `false` | | ||
| justHeaders | _boolean_ | Whether to stop the request after response headers were received, without waiting for the data. | `false` | | ||
| Name | Type | Description | Default | | ||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | ||
| data | <em>!Object</em> | Optional data to send to the server with the request. | - | | ||
| type | <em>string</em> | How to send data: `json` to serialise JSON data and add _Content-Type: application/json_ header, and `form` for url-encoded transmission with _Content-Type: application/x-www-form-urlencoded_. _Multipart/form-data_ must be implemented manually. | `json` | | ||
| headers | <em><a href="#type-httpoutgoinghttpheaders" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">!http.OutgoingHttpHeaders</a></em> | Headers to use for the request. By default, a single User-Agent header with _Mozilla/5.0 (Node.JS) aqt/{version}_ value is set. | - | | ||
| compress | <em>boolean</em> | Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. | `true` | | ||
| timeout | <em>number</em> | The timeout after which the request should fail. | - | | ||
| method | <em>string</em> | What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | - | | ||
| binary | <em>boolean</em> | Whether to return a buffer instead of a string. | `false` | | ||
| justHeaders | <em>boolean</em> | Whether to stop the request after response headers were received, without waiting for the data. | `false` | | ||
`import('http').IncomingHttpHeaders` __<a name="type-httpincominghttpheaders">`http.IncomingHttpHeaders`</a>__ | ||
__<a name="type-aqtreturn">`AqtReturn`</a>__ | ||
__<a name="type-aqtreturn">`AqtReturn`</a>__: The return type of the function. | ||
| Name | Type | Description | | ||
| ------------------ | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| __body*__ | _string \| Object \| Buffer_ | The return from the server. In case the `json` content-type was set by the server, the response will be parsed into an object. If `binary` option was used for the request, a `Buffer` will be returned. Otherwise, a string response is returned. | | ||
| __headers*__ | _[http.IncomingHttpHeaders](#type-httpincominghttpheaders)_ | Incoming headers returned by the server. | | ||
| __statusCode*__ | _number_ | The status code returned by the server. | | ||
| __statusMessage*__ | _string_ | The status message set by the server. | | ||
| Name | Type | Description | | ||
| ------------------ | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| __body*__ | <em>!(string \| Object \| Buffer)</em> | The return from the server. In case the `json` content-type was set by the server, the response will be parsed into an object. If `binary` option was used for the request, a `Buffer` will be returned. Otherwise, a string response is returned. | | ||
| __headers*__ | <em>[!http.IncomingHttpHeaders](#type-httpincominghttpheaders)</em> | Incoming headers returned by the server. | | ||
| __statusCode*__ | <em>number</em> | The status code returned by the server. | | ||
| __statusMessage*__ | <em>string</em> | The status message set by the server. | | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/6.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/6.svg?sanitize=true"></a></p> | ||
@@ -260,6 +260,6 @@ ## `Session` Class | ||
| Name | Type | Description | | ||
| ------- | --------------------- | ------------------------------------------------------ | | ||
| host | _string_ | The prefix to each request, such as `https://rqt.biz`. | | ||
| headers | _OutgoingHttpHeaders_ | Headers to use for each request. | | ||
| Name | Type | Description | | ||
| ------- | ---------------------------- | ------------------------------------------------------ | | ||
| host | <em>string</em> | The prefix to each request, such as `https://rqt.biz`. | | ||
| headers | <em>OutgoingHttpHeaders</em> | Headers to use for each request. | | ||
@@ -314,7 +314,8 @@ The methods in the _Session_ class are proxied to the respective methods in the API, but the cookies and session's headers will be set automatically. | ||
```js | ||
import idioCore from '@idio/core' | ||
import idioCore from '@idio/idio' | ||
import { collect } from 'catchment' | ||
import { parse } from 'querystring' | ||
const Server = async () => { | ||
const { url, app, router } = await idioCore({ | ||
/** @type {import('koa').Middleware} */ | ||
const { url, app } = await idioCore({ | ||
async error(ctx, next) { | ||
@@ -329,31 +330,36 @@ try { | ||
session: { use: true, keys: ['example'] }, | ||
bodyparser: { use: true }, | ||
async bodyparser(ctx, next) { | ||
const data = await collect(ctx.req) | ||
if (data) ctx.request.body = parse(data) | ||
await next() | ||
}, | ||
}, { port: 5002 }) | ||
router.get('/StartSession', async (ctx, next) => { | ||
ctx.session.SessionKey = 'Example-4736gst4yd' | ||
ctx.body = { | ||
SessionKey: ctx.session.SessionKey, | ||
app.use((ctx) => { | ||
switch (ctx.path) { | ||
case '/StartSession': | ||
ctx.session.SessionKey = 'Example-4736gst4yd' | ||
ctx.body = { | ||
SessionKey: ctx.session.SessionKey, | ||
} | ||
break | ||
case '/Login': { | ||
const { sessionEncryptValue } = ctx.request.body | ||
if (!sessionEncryptValue) { | ||
throw new Error('Missing session key.') | ||
} | ||
if (sessionEncryptValue != ctx.session.SessionKey) { | ||
throw new Error('Incorrect session key.') | ||
} | ||
ctx.session.user = ctx.request.body.LoginUserName | ||
ctx.redirect('/Portal') | ||
break | ||
} | ||
await next() | ||
}) | ||
router.post('/Login', async (ctx, next) => { | ||
const { sessionEncryptValue } = ctx.request.body | ||
if (!sessionEncryptValue) { | ||
throw new Error('Missing session key.') | ||
case '/Portal': | ||
if (!ctx.session.user) { | ||
throw new Error('Not authorized.') | ||
} | ||
ctx.body = `Hello, ${ctx.session.user}` | ||
break | ||
} | ||
if (sessionEncryptValue != ctx.session.SessionKey) { | ||
throw new Error('Incorrect session key.') | ||
} | ||
ctx.session.user = ctx.request.body.LoginUserName | ||
ctx.redirect('/Portal') | ||
await next() | ||
}) | ||
router.get('/Portal', async (ctx, next) => { | ||
if (!ctx.session.user) { | ||
throw new Error('Not authorized.') | ||
} | ||
ctx.body = `Hello, ${ctx.session.user}` | ||
await next() | ||
}) | ||
app.use(router.routes()) | ||
return url | ||
@@ -382,3 +388,3 @@ } | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/7.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/7.svg?sanitize=true"></a></p> | ||
@@ -391,3 +397,4 @@ ## Copyright | ||
<a href="https://artd.eco"> | ||
<img src="https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png" alt="Art Deco" /> | ||
<img width="100" src="https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png" | ||
alt="Art Deco"> | ||
</a> | ||
@@ -398,4 +405,4 @@ </th> | ||
<a href="https://www.technation.sucks" title="Tech Nation Visa"> | ||
<img src="https://raw.githubusercontent.com/artdecoweb/www.technation.sucks/master/anim.gif" | ||
alt="Tech Nation Visa" /> | ||
<img width="100" src="https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg" | ||
alt="Tech Nation Visa"> | ||
</a> | ||
@@ -407,2 +414,2 @@ </th> | ||
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/-1.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/-1.svg?sanitize=true"></a></p> |
@@ -9,3 +9,3 @@ import aqt from '@rqt/aqt' | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -28,3 +28,3 @@ * @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -47,3 +47,3 @@ * @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -70,3 +70,3 @@ * @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {'form'|'json'} [config.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [config.headers] Headers to use for the request. | ||
* @param {http.OutgoingHttpHeaders} [config.headers] Headers to use for the request. | ||
* @param {boolean} [config.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -85,8 +85,7 @@ * @param {string} [config.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
/** | ||
* @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders | ||
* | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} Options Options for requests. | ||
* @prop {*} [data] Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {http.OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -96,1 +95,5 @@ * @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ |
@@ -10,4 +10,4 @@ import aqt from '@rqt/aqt' | ||
* @param {SessionOptions} options Options for a session. | ||
* @param {string} [options.host] The prefix to each request, such as `https://rqt.biz`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for each request. | ||
* @param {string} [options.host] The prefix to each request, such as `https://rqt.biz`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for each request. | ||
*/ | ||
@@ -28,8 +28,8 @@ constructor(options = {}) { | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
*/ | ||
@@ -46,8 +46,8 @@ async rqt(location, options = {}) { | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
*/ | ||
@@ -67,8 +67,8 @@ async bqt(location, options = {}) { | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
*/ | ||
@@ -142,4 +142,4 @@ async jqt(location, options = {}) { | ||
/** | ||
* @param {Object} cookies | ||
* @param {import('http').IncomingHttpHeaders} headers | ||
* @param {!Object} cookies | ||
* @param {http.IncomingHttpHeaders} headers | ||
*/ | ||
@@ -181,10 +181,9 @@ const updateCookies = (cookies, headers) => { | ||
/* documentary types/options.xml */ | ||
/* typal types/options.xml */ | ||
/** | ||
* @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders | ||
* | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} Options Options for requests. | ||
* @prop {*} [data] Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {http.OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -194,5 +193,10 @@ * @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
/* documentary types/session.xml */ | ||
/* typal types/session.xml */ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} SessionOptions Options for a session. | ||
@@ -203,10 +207,13 @@ * @prop {string} [host] The prefix to each request, such as `https://rqt.biz`. | ||
/* documentary node_modules/@rqt/aqt/types/index.xml */ | ||
/* typal node_modules/@rqt/aqt/types/index.xml */ | ||
/** | ||
* @typedef {import('http').OutgoingHttpHeaders} OutgoingHttpHeaders | ||
* | ||
* @typedef {Object} AqtOptions Configuration for requests. | ||
* @prop {Object} data Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {_rqt.AqtOptions} AqtOptions Configuration for requests. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} _rqt.AqtOptions Configuration for requests. | ||
* @prop {!Object} [data] Optional data to send to the server with the request. | ||
* @prop {string} [type="json"] How to send data: `json` to serialise JSON data and add _Content-Type: application/json_ header, and `form` for url-encoded transmission with _Content-Type: application/x-www-form-urlencoded_. _Multipart/form-data_ must be implemented manually. Default `json`. | ||
* @prop {!http.OutgoingHttpHeaders} [headers] Headers to use for the request. By default, a single User-Agent header with _Mozilla/5.0 (Node.JS) aqt/{version}_ value is set. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
@@ -218,1 +225,10 @@ * @prop {number} [timeout] The timeout after which the request should fail. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').IncomingHttpHeaders} http.IncomingHttpHeaders | ||
*/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58072
619
398
Updated@rqt/aqt@^1.3.0