@discordjs/proxy 1.1.0-dev.1660910640-e475b63.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@discordjs/proxy@1.1.0](https://github.com/discordjs/discord.js/tree/@discordjs/proxy@1.1.0) - (2022-08-22)
|
|
6
|
+
|
|
7
|
+
## Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **proxyRequests:** Typo in error message (#8537) ([dd44e8b](https://github.com/discordjs/discord.js/commit/dd44e8b6ec141e630af4543bd3babcce39aa2887))
|
|
10
|
+
- **proxy-container:** Proper deps (#8120) ([17867f9](https://github.com/discordjs/discord.js/commit/17867f9154d0dd16357f4ff29da641e23a33a9fa))
|
|
11
|
+
- **proxy:** Add docs script ([a45bef4](https://github.com/discordjs/discord.js/commit/a45bef4cad77dac1a4138fd0d52b769ce09b5678))
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
- Add codecov coverage badge to readmes (#8226) ([f6db285](https://github.com/discordjs/discord.js/commit/f6db285c073898a749fe4591cbd4463d1896daf5))
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **website:** Show `constructor` information (#8540) ([e42fd16](https://github.com/discordjs/discord.js/commit/e42fd1636973b10dd7ed6fb4280ee1a4a8f82007))
|
|
20
|
+
- Codecov (#8219) ([f10f4cd](https://github.com/discordjs/discord.js/commit/f10f4cdcd88ca6be7ec735ed3a415ba13da83db0))
|
|
21
|
+
- Proxy container (#8000) ([2681929](https://github.com/discordjs/discord.js/commit/2681929e4263032ad34a99ecb42465c320b271ba))
|
|
22
|
+
- **docgen:** Update typedoc ([b3346f4](https://github.com/discordjs/discord.js/commit/b3346f4b9b3d4f96443506643d4631dc1c6d7b21))
|
|
23
|
+
- Website (#8043) ([127931d](https://github.com/discordjs/discord.js/commit/127931d1df7a2a5c27923c2f2151dbf3824e50cc))
|
|
24
|
+
- **docgen:** Typescript support ([3279b40](https://github.com/discordjs/discord.js/commit/3279b40912e6aa61507bedb7db15a2b8668de44b))
|
|
25
|
+
- Docgen package (#8029) ([8b979c0](https://github.com/discordjs/discord.js/commit/8b979c0245c42fd824d8e98745ee869f5360fc86))
|
|
26
|
+
- Use vitest instead of jest for more speed ([8d8e6c0](https://github.com/discordjs/discord.js/commit/8d8e6c03decd7352a2aa180f6e5bc1a13602539b))
|
|
27
|
+
- Add scripts package for locally used scripts ([f2ae1f9](https://github.com/discordjs/discord.js/commit/f2ae1f9348bfd893332a9060f71a8a5f272a1b8b))
|
|
28
|
+
- @discordjs/proxy (#7925) ([1ba2d2a](https://github.com/discordjs/discord.js/commit/1ba2d2a898613e5fcc119a97dce935f4db91162c))
|
|
29
|
+
|
|
30
|
+
## Refactor
|
|
31
|
+
|
|
32
|
+
- Docs design (#8487) ([4ab1d09](https://github.com/discordjs/discord.js/commit/4ab1d09997a18879a9eb9bda39df6f15aa22557e))
|
|
33
|
+
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
|
|
34
|
+
|
|
35
|
+
## Styling
|
|
36
|
+
|
|
37
|
+
- Cleanup tests and tsup configs ([6b8ef20](https://github.com/discordjs/discord.js/commit/6b8ef20cb3af5b5cfd176dd0aa0a1a1e98551629))
|
|
38
|
+
|
|
5
39
|
# [@discordjs/proxy@1.0.0](https://github.com/discordjs/discord.js/tree/@discordjs/proxy@1.1.0) - (2022-07-17)
|
|
6
40
|
|
|
7
41
|
## Bug Fixes
|
|
@@ -11,7 +11,7 @@ function proxyRequests(rest$1) {
|
|
|
11
11
|
const { method, url } = req;
|
|
12
12
|
if (!method || !url) {
|
|
13
13
|
throw new TypeError(
|
|
14
|
-
"Invalid request. Missing method and/or url, implying that this is not a Server
|
|
14
|
+
"Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage"
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
const fullRoute = new node_url.URL(url, "http://noop").pathname.replace(/^\/api(\/v\d+)?/, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyRequests.cjs","sources":["../../src/handlers/proxyRequests.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport { DiscordAPIError, HTTPError, RateLimitError, RequestMethod, REST, RouteLike } from '@discordjs/rest';\nimport {\n\tpopulateAbortErrorResponse,\n\tpopulateGeneralErrorResponse,\n\tpopulateSuccessfulResponse,\n\tpopulateRatelimitErrorResponse,\n} from '../util/responseHelpers';\nimport type { RequestHandler } from '../util/util';\n\n/**\n * Creates an HTTP handler used to forward requests to Discord\n *\n * @param rest - REST instance to use for the requests\n */\nexport function proxyRequests(rest: REST): RequestHandler {\n\treturn async (req, res) => {\n\t\tconst { method, url } = req;\n\n\t\tif (!method || !url) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Invalid request. Missing method and/or url, implying that this is not a Server
|
|
1
|
+
{"version":3,"file":"proxyRequests.cjs","sources":["../../src/handlers/proxyRequests.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport { DiscordAPIError, HTTPError, RateLimitError, RequestMethod, REST, RouteLike } from '@discordjs/rest';\nimport {\n\tpopulateAbortErrorResponse,\n\tpopulateGeneralErrorResponse,\n\tpopulateSuccessfulResponse,\n\tpopulateRatelimitErrorResponse,\n} from '../util/responseHelpers';\nimport type { RequestHandler } from '../util/util';\n\n/**\n * Creates an HTTP handler used to forward requests to Discord\n *\n * @param rest - REST instance to use for the requests\n */\nexport function proxyRequests(rest: REST): RequestHandler {\n\treturn async (req, res) => {\n\t\tconst { method, url } = req;\n\n\t\tif (!method || !url) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage',\n\t\t\t);\n\t\t}\n\n\t\t// The 2nd parameter is here so the URL constructor doesn't complain about an \"invalid url\" when the origin is missing\n\t\t// we don't actually care about the origin and the value passed is irrelevant\n\t\tconst fullRoute = new URL(url, 'http://noop').pathname.replace(/^\\/api(\\/v\\d+)?/, '') as RouteLike;\n\n\t\ttry {\n\t\t\tconst discordResponse = await rest.raw({\n\t\t\t\tbody: req,\n\t\t\t\tfullRoute,\n\t\t\t\t// This type cast is technically incorrect, but we want Discord to throw Method Not Allowed for us\n\t\t\t\tmethod: method as RequestMethod,\n\t\t\t\tpassThroughBody: true,\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': req.headers['content-type']!,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tawait populateSuccessfulResponse(res, discordResponse);\n\t\t} catch (error) {\n\t\t\tif (error instanceof DiscordAPIError || error instanceof HTTPError) {\n\t\t\t\tpopulateGeneralErrorResponse(res, error);\n\t\t\t} else if (error instanceof RateLimitError) {\n\t\t\t\tpopulateRatelimitErrorResponse(res, error);\n\t\t\t} else if (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tpopulateAbortErrorResponse(res);\n\t\t\t} else {\n\t\t\t\t// Unclear if there's better course of action here for unknown erorrs. Any web framework allows to pass in an error handler for something like this\n\t\t\t\t// at which point the user could dictate what to do with the error - otherwise we could just 500\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} finally {\n\t\t\tres.end();\n\t\t}\n\t};\n}\n"],"names":["rest","URL","populateSuccessfulResponse","DiscordAPIError","HTTPError","populateGeneralErrorResponse","RateLimitError","populateRatelimitErrorResponse","populateAbortErrorResponse"],"mappings":";;;;;;;;AAQO,SAAS,aAAa,CAACA,MAAI,EAAE;AACpC,EAAE,OAAO,OAAO,GAAG,EAAE,GAAG,KAAK;AAC7B,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAChC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE;AACzB,MAAM,MAAM,IAAI,SAAS;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10
|
-
"Invalid request. Missing method and/or url, implying that this is not a Server
|
|
10
|
+
"Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage"
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
const fullRoute = new URL(url, "http://noop").pathname.replace(/^\/api(\/v\d+)?/, "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyRequests.mjs","sources":["../../src/handlers/proxyRequests.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport { DiscordAPIError, HTTPError, RateLimitError, RequestMethod, REST, RouteLike } from '@discordjs/rest';\nimport {\n\tpopulateAbortErrorResponse,\n\tpopulateGeneralErrorResponse,\n\tpopulateSuccessfulResponse,\n\tpopulateRatelimitErrorResponse,\n} from '../util/responseHelpers';\nimport type { RequestHandler } from '../util/util';\n\n/**\n * Creates an HTTP handler used to forward requests to Discord\n *\n * @param rest - REST instance to use for the requests\n */\nexport function proxyRequests(rest: REST): RequestHandler {\n\treturn async (req, res) => {\n\t\tconst { method, url } = req;\n\n\t\tif (!method || !url) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Invalid request. Missing method and/or url, implying that this is not a Server
|
|
1
|
+
{"version":3,"file":"proxyRequests.mjs","sources":["../../src/handlers/proxyRequests.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport { DiscordAPIError, HTTPError, RateLimitError, RequestMethod, REST, RouteLike } from '@discordjs/rest';\nimport {\n\tpopulateAbortErrorResponse,\n\tpopulateGeneralErrorResponse,\n\tpopulateSuccessfulResponse,\n\tpopulateRatelimitErrorResponse,\n} from '../util/responseHelpers';\nimport type { RequestHandler } from '../util/util';\n\n/**\n * Creates an HTTP handler used to forward requests to Discord\n *\n * @param rest - REST instance to use for the requests\n */\nexport function proxyRequests(rest: REST): RequestHandler {\n\treturn async (req, res) => {\n\t\tconst { method, url } = req;\n\n\t\tif (!method || !url) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage',\n\t\t\t);\n\t\t}\n\n\t\t// The 2nd parameter is here so the URL constructor doesn't complain about an \"invalid url\" when the origin is missing\n\t\t// we don't actually care about the origin and the value passed is irrelevant\n\t\tconst fullRoute = new URL(url, 'http://noop').pathname.replace(/^\\/api(\\/v\\d+)?/, '') as RouteLike;\n\n\t\ttry {\n\t\t\tconst discordResponse = await rest.raw({\n\t\t\t\tbody: req,\n\t\t\t\tfullRoute,\n\t\t\t\t// This type cast is technically incorrect, but we want Discord to throw Method Not Allowed for us\n\t\t\t\tmethod: method as RequestMethod,\n\t\t\t\tpassThroughBody: true,\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': req.headers['content-type']!,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tawait populateSuccessfulResponse(res, discordResponse);\n\t\t} catch (error) {\n\t\t\tif (error instanceof DiscordAPIError || error instanceof HTTPError) {\n\t\t\t\tpopulateGeneralErrorResponse(res, error);\n\t\t\t} else if (error instanceof RateLimitError) {\n\t\t\t\tpopulateRatelimitErrorResponse(res, error);\n\t\t\t} else if (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tpopulateAbortErrorResponse(res);\n\t\t\t} else {\n\t\t\t\t// Unclear if there's better course of action here for unknown erorrs. Any web framework allows to pass in an error handler for something like this\n\t\t\t\t// at which point the user could dictate what to do with the error - otherwise we could just 500\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} finally {\n\t\t\tres.end();\n\t\t}\n\t};\n}\n"],"names":[],"mappings":";;;;AAQO,SAAS,aAAa,CAAC,IAAI,EAAE;AACpC,EAAE,OAAO,OAAO,GAAG,EAAE,GAAG,KAAK;AAC7B,IAAI,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAChC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE;AACzB,MAAM,MAAM,IAAI,SAAS;AACzB,QAAQ,gGAAgG;AACxG,OAAO,CAAC;AACR,KAAK;AACL,IAAI,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAC1F,IAAI,IAAI;AACR,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC;AAC7C,QAAQ,IAAI,EAAE,GAAG;AACjB,QAAQ,SAAS;AACjB,QAAQ,MAAM;AACd,QAAQ,eAAe,EAAE,IAAI;AAC7B,QAAQ,OAAO,EAAE;AACjB,UAAU,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC;AACrD,SAAS;AACT,OAAO,CAAC,CAAC;AACT,MAAM,MAAM,0BAA0B,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AAC7D,KAAK,CAAC,OAAO,KAAK,EAAE;AACpB,MAAM,IAAI,KAAK,YAAY,eAAe,IAAI,KAAK,YAAY,SAAS,EAAE;AAC1E,QAAQ,4BAA4B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACjD,OAAO,MAAM,IAAI,KAAK,YAAY,cAAc,EAAE;AAClD,QAAQ,8BAA8B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACnD,OAAO,MAAM,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AACxE,QAAQ,0BAA0B,CAAC,GAAG,CAAC,CAAC;AACxC,OAAO,MAAM;AACb,QAAQ,MAAM,KAAK,CAAC;AACpB,OAAO;AACP,KAAK,SAAS;AACd,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC;AAChB,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordjs/proxy",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Tools for running an HTTP proxy for Discord's API",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest run",
|
|
@@ -56,29 +56,29 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@discordjs/rest": "^1.0.0",
|
|
58
58
|
"tslib": "^2.4.0",
|
|
59
|
-
"undici": "^5.
|
|
59
|
+
"undici": "^5.9.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@discordjs/docgen": "^0.12.1",
|
|
63
|
-
"@favware/cliff-jumper": "^1.8.
|
|
64
|
-
"@microsoft/api-extractor": "^7.29.
|
|
65
|
-
"@types/node": "^16.11.
|
|
63
|
+
"@favware/cliff-jumper": "^1.8.7",
|
|
64
|
+
"@microsoft/api-extractor": "^7.29.3",
|
|
65
|
+
"@types/node": "^16.11.52",
|
|
66
66
|
"@types/supertest": "^2.0.12",
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^5.33.
|
|
68
|
-
"@typescript-eslint/parser": "^5.33.
|
|
69
|
-
"@vitest/coverage-c8": "^0.22.
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
|
68
|
+
"@typescript-eslint/parser": "^5.33.1",
|
|
69
|
+
"@vitest/coverage-c8": "^0.22.1",
|
|
70
70
|
"downlevel-dts": "^0.10.0",
|
|
71
71
|
"eslint": "^8.22.0",
|
|
72
72
|
"eslint-config-marine": "^9.4.1",
|
|
73
73
|
"eslint-config-prettier": "^8.5.0",
|
|
74
|
-
"eslint-import-resolver-typescript": "^3.4.
|
|
74
|
+
"eslint-import-resolver-typescript": "^3.4.2",
|
|
75
75
|
"eslint-plugin-import": "^2.26.0",
|
|
76
76
|
"prettier": "^2.7.1",
|
|
77
|
-
"rollup-plugin-typescript2": "0.
|
|
77
|
+
"rollup-plugin-typescript2": "^0.33.0",
|
|
78
78
|
"supertest": "^6.2.4",
|
|
79
79
|
"typescript": "^4.7.4",
|
|
80
|
-
"unbuild": "^0.8.
|
|
81
|
-
"vitest": "^0.22.
|
|
80
|
+
"unbuild": "^0.8.9",
|
|
81
|
+
"vitest": "^0.22.1"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=16.9.0"
|