@discordjs/proxy 1.2.0-dev.1661213496-2ecb862.0 → 1.2.0-dev.1662250231-d08a57c.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/dist/index.d.ts +49 -4
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +88 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -18
- package/dist/handlers/proxyRequests.cjs +0 -46
- package/dist/handlers/proxyRequests.cjs.map +0 -1
- package/dist/handlers/proxyRequests.d.ts +0 -9
- package/dist/handlers/proxyRequests.d.ts.map +0 -1
- package/dist/handlers/proxyRequests.mjs +0 -42
- package/dist/handlers/proxyRequests.mjs.map +0 -1
- package/dist/index.cjs +0 -15
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/util/responseHelpers.cjs +0 -37
- package/dist/util/responseHelpers.cjs.map +0 -1
- package/dist/util/responseHelpers.d.ts +0 -32
- package/dist/util/responseHelpers.d.ts.map +0 -1
- package/dist/util/responseHelpers.mjs +0 -30
- package/dist/util/responseHelpers.mjs.map +0 -1
- package/dist/util/util.d.ts +0 -11
- package/dist/util/util.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { REST, DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import { Dispatcher } from 'undici';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a potentially awaitable value
|
|
7
|
+
*/
|
|
8
|
+
declare type Awaitable<T> = PromiseLike<T> | T;
|
|
9
|
+
/**
|
|
10
|
+
* Represents a simple HTTP request handler
|
|
11
|
+
*/
|
|
12
|
+
declare type RequestHandler = (req: IncomingMessage, res: ServerResponse) => Awaitable<void>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates an HTTP handler used to forward requests to Discord
|
|
16
|
+
*
|
|
17
|
+
* @param rest - REST instance to use for the requests
|
|
18
|
+
*/
|
|
19
|
+
declare function proxyRequests(rest: REST): RequestHandler;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Populates a server response with the data from a Discord 2xx REST response
|
|
23
|
+
*
|
|
24
|
+
* @param res - The server response to populate
|
|
25
|
+
* @param data - The data to populate the response with
|
|
26
|
+
*/
|
|
27
|
+
declare function populateSuccessfulResponse(res: ServerResponse, data: Dispatcher.ResponseData): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429
|
|
30
|
+
*
|
|
31
|
+
* @param res - The server response to populate
|
|
32
|
+
* @param error - The error to populate the response with
|
|
33
|
+
*/
|
|
34
|
+
declare function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void;
|
|
35
|
+
/**
|
|
36
|
+
* Populates a server response with the data from a Discord 429 REST response
|
|
37
|
+
*
|
|
38
|
+
* @param res - The server response to populate
|
|
39
|
+
* @param error - The error to populate the response with
|
|
40
|
+
*/
|
|
41
|
+
declare function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void;
|
|
42
|
+
/**
|
|
43
|
+
* Populates a server response with data relevant for a timeout
|
|
44
|
+
*
|
|
45
|
+
* @param res - The sever response to populate
|
|
46
|
+
*/
|
|
47
|
+
declare function populateAbortErrorResponse(res: ServerResponse): void;
|
|
48
|
+
|
|
49
|
+
export { RequestHandler, populateAbortErrorResponse, populateGeneralErrorResponse, populateRatelimitErrorResponse, populateSuccessfulResponse, proxyRequests };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
populateAbortErrorResponse: () => populateAbortErrorResponse,
|
|
25
|
+
populateGeneralErrorResponse: () => populateGeneralErrorResponse,
|
|
26
|
+
populateRatelimitErrorResponse: () => populateRatelimitErrorResponse,
|
|
27
|
+
populateSuccessfulResponse: () => populateSuccessfulResponse,
|
|
28
|
+
proxyRequests: () => proxyRequests
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
|
|
32
|
+
// src/handlers/proxyRequests.ts
|
|
33
|
+
var import_node_url = require("url");
|
|
34
|
+
var import_rest = require("@discordjs/rest");
|
|
35
|
+
|
|
36
|
+
// src/util/responseHelpers.ts
|
|
37
|
+
var import_promises = require("stream/promises");
|
|
38
|
+
async function populateSuccessfulResponse(res, data) {
|
|
39
|
+
res.statusCode = data.statusCode;
|
|
40
|
+
for (const header of Object.keys(data.headers)) {
|
|
41
|
+
if (header.startsWith("x-ratelimit")) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
res.setHeader(header, data.headers[header]);
|
|
45
|
+
}
|
|
46
|
+
await (0, import_promises.pipeline)(data.body, res);
|
|
47
|
+
}
|
|
48
|
+
__name(populateSuccessfulResponse, "populateSuccessfulResponse");
|
|
49
|
+
function populateGeneralErrorResponse(res, error) {
|
|
50
|
+
res.statusCode = error.status;
|
|
51
|
+
if ("rawError" in error) {
|
|
52
|
+
res.setHeader("Content-Type", "application/json");
|
|
53
|
+
res.write(JSON.stringify(error.rawError));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
__name(populateGeneralErrorResponse, "populateGeneralErrorResponse");
|
|
57
|
+
function populateRatelimitErrorResponse(res, error) {
|
|
58
|
+
res.statusCode = 429;
|
|
59
|
+
res.setHeader("Retry-After", error.timeToReset / 1e3);
|
|
60
|
+
}
|
|
61
|
+
__name(populateRatelimitErrorResponse, "populateRatelimitErrorResponse");
|
|
62
|
+
function populateAbortErrorResponse(res) {
|
|
63
|
+
res.statusCode = 504;
|
|
64
|
+
res.statusMessage = "Upstream timed out";
|
|
65
|
+
}
|
|
66
|
+
__name(populateAbortErrorResponse, "populateAbortErrorResponse");
|
|
67
|
+
|
|
68
|
+
// src/handlers/proxyRequests.ts
|
|
69
|
+
function proxyRequests(rest) {
|
|
70
|
+
return async (req, res) => {
|
|
71
|
+
const { method, url } = req;
|
|
72
|
+
if (!method || !url) {
|
|
73
|
+
throw new TypeError(
|
|
74
|
+
"Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const fullRoute = new import_node_url.URL(url, "http://noop").pathname.replace(/^\/api(\/v\d+)?/, "");
|
|
78
|
+
try {
|
|
79
|
+
const discordResponse = await rest.raw({
|
|
80
|
+
body: req,
|
|
81
|
+
fullRoute,
|
|
82
|
+
method,
|
|
83
|
+
passThroughBody: true,
|
|
84
|
+
headers: {
|
|
85
|
+
"Content-Type": req.headers["content-type"]
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
await populateSuccessfulResponse(res, discordResponse);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof import_rest.DiscordAPIError || error instanceof import_rest.HTTPError) {
|
|
91
|
+
populateGeneralErrorResponse(res, error);
|
|
92
|
+
} else if (error instanceof import_rest.RateLimitError) {
|
|
93
|
+
populateRatelimitErrorResponse(res, error);
|
|
94
|
+
} else if (error instanceof Error && error.name === "AbortError") {
|
|
95
|
+
populateAbortErrorResponse(res);
|
|
96
|
+
} else {
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
res.end();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
__name(proxyRequests, "proxyRequests");
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
populateAbortErrorResponse,
|
|
108
|
+
populateGeneralErrorResponse,
|
|
109
|
+
populateRatelimitErrorResponse,
|
|
110
|
+
populateSuccessfulResponse,
|
|
111
|
+
proxyRequests
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/handlers/proxyRequests.ts","../src/util/responseHelpers.ts"],"sourcesContent":["export * from './handlers/proxyRequests.js';\nexport * from './util/responseHelpers.js';\nexport type { RequestHandler } from './util/util.js';\n","import { URL } from 'node:url';\nimport {\n\tDiscordAPIError,\n\tHTTPError,\n\tRateLimitError,\n\ttype RequestMethod,\n\ttype REST,\n\ttype RouteLike,\n} from '@discordjs/rest';\nimport {\n\tpopulateAbortErrorResponse,\n\tpopulateGeneralErrorResponse,\n\tpopulateSuccessfulResponse,\n\tpopulateRatelimitErrorResponse,\n} from '../util/responseHelpers.js';\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\t// eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex\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","import type { ServerResponse } from 'node:http';\nimport { pipeline } from 'node:stream/promises';\nimport type { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';\nimport type { Dispatcher } from 'undici';\n\n/**\n * Populates a server response with the data from a Discord 2xx REST response\n *\n * @param res - The server response to populate\n * @param data - The data to populate the response with\n */\nexport async function populateSuccessfulResponse(res: ServerResponse, data: Dispatcher.ResponseData): Promise<void> {\n\tres.statusCode = data.statusCode;\n\n\tfor (const header of Object.keys(data.headers)) {\n\t\t// Strip ratelimit headers\n\t\tif (header.startsWith('x-ratelimit')) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tres.setHeader(header, data.headers[header]!);\n\t}\n\n\tawait pipeline(data.body, res);\n}\n\n/**\n * Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void {\n\tres.statusCode = error.status;\n\n\tif ('rawError' in error) {\n\t\tres.setHeader('Content-Type', 'application/json');\n\t\tres.write(JSON.stringify(error.rawError));\n\t}\n}\n\n/**\n * Populates a server response with the data from a Discord 429 REST response\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void {\n\tres.statusCode = 429;\n\tres.setHeader('Retry-After', error.timeToReset / 1_000);\n}\n\n/**\n * Populates a server response with data relevant for a timeout\n *\n * @param res - The sever response to populate\n */\nexport function populateAbortErrorResponse(res: ServerResponse): void {\n\tres.statusCode = 504;\n\tres.statusMessage = 'Upstream timed out';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAoB;AACpB,kBAOO;;;ACPP,sBAAyB;AAUzB,eAAsB,2BAA2B,KAAqB,MAA8C;AACnH,MAAI,aAAa,KAAK;AAEtB,aAAW,UAAU,OAAO,KAAK,KAAK,OAAO,GAAG;AAE/C,QAAI,OAAO,WAAW,aAAa,GAAG;AACrC;AAAA,IACD;AAEA,QAAI,UAAU,QAAQ,KAAK,QAAQ,OAAQ;AAAA,EAC5C;AAEA,YAAM,0BAAS,KAAK,MAAM,GAAG;AAC9B;AAbsB;AAqBf,SAAS,6BAA6B,KAAqB,OAA0C;AAC3G,MAAI,aAAa,MAAM;AAEvB,MAAI,cAAc,OAAO;AACxB,QAAI,UAAU,gBAAgB,kBAAkB;AAChD,QAAI,MAAM,KAAK,UAAU,MAAM,QAAQ,CAAC;AAAA,EACzC;AACD;AAPgB;AAeT,SAAS,+BAA+B,KAAqB,OAA6B;AAChG,MAAI,aAAa;AACjB,MAAI,UAAU,eAAe,MAAM,cAAc,GAAK;AACvD;AAHgB;AAUT,SAAS,2BAA2B,KAA2B;AACrE,MAAI,aAAa;AACjB,MAAI,gBAAgB;AACrB;AAHgB;;;ADnCT,SAAS,cAAc,MAA4B;AACzD,SAAO,OAAO,KAAK,QAAQ;AAC1B,UAAM,EAAE,QAAQ,IAAI,IAAI;AAExB,QAAI,CAAC,UAAU,CAAC,KAAK;AACpB,YAAM,IAAI;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAKA,UAAM,YAAY,IAAI,oBAAI,KAAK,aAAa,EAAE,SAAS,QAAQ,mBAAmB,EAAE;AAEpF,QAAI;AACH,YAAM,kBAAkB,MAAM,KAAK,IAAI;AAAA,QACtC,MAAM;AAAA,QACN;AAAA,QAEA;AAAA,QACA,iBAAiB;AAAA,QACjB,SAAS;AAAA,UACR,gBAAgB,IAAI,QAAQ;AAAA,QAC7B;AAAA,MACD,CAAC;AAED,YAAM,2BAA2B,KAAK,eAAe;AAAA,IACtD,SAAS,OAAP;AACD,UAAI,iBAAiB,+BAAmB,iBAAiB,uBAAW;AACnE,qCAA6B,KAAK,KAAK;AAAA,MACxC,WAAW,iBAAiB,4BAAgB;AAC3C,uCAA+B,KAAK,KAAK;AAAA,MAC1C,WAAW,iBAAiB,SAAS,MAAM,SAAS,cAAc;AACjE,mCAA2B,GAAG;AAAA,MAC/B,OAAO;AAGN,cAAM;AAAA,MACP;AAAA,IACD,UAAE;AACD,UAAI,IAAI;AAAA,IACT;AAAA,EACD;AACD;AA5CgB;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/handlers/proxyRequests.ts
|
|
5
|
+
import { URL } from "node:url";
|
|
6
|
+
import {
|
|
7
|
+
DiscordAPIError,
|
|
8
|
+
HTTPError,
|
|
9
|
+
RateLimitError
|
|
10
|
+
} from "@discordjs/rest";
|
|
11
|
+
|
|
12
|
+
// src/util/responseHelpers.ts
|
|
13
|
+
import { pipeline } from "node:stream/promises";
|
|
14
|
+
async function populateSuccessfulResponse(res, data) {
|
|
15
|
+
res.statusCode = data.statusCode;
|
|
16
|
+
for (const header of Object.keys(data.headers)) {
|
|
17
|
+
if (header.startsWith("x-ratelimit")) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
res.setHeader(header, data.headers[header]);
|
|
21
|
+
}
|
|
22
|
+
await pipeline(data.body, res);
|
|
23
|
+
}
|
|
24
|
+
__name(populateSuccessfulResponse, "populateSuccessfulResponse");
|
|
25
|
+
function populateGeneralErrorResponse(res, error) {
|
|
26
|
+
res.statusCode = error.status;
|
|
27
|
+
if ("rawError" in error) {
|
|
28
|
+
res.setHeader("Content-Type", "application/json");
|
|
29
|
+
res.write(JSON.stringify(error.rawError));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
__name(populateGeneralErrorResponse, "populateGeneralErrorResponse");
|
|
33
|
+
function populateRatelimitErrorResponse(res, error) {
|
|
34
|
+
res.statusCode = 429;
|
|
35
|
+
res.setHeader("Retry-After", error.timeToReset / 1e3);
|
|
36
|
+
}
|
|
37
|
+
__name(populateRatelimitErrorResponse, "populateRatelimitErrorResponse");
|
|
38
|
+
function populateAbortErrorResponse(res) {
|
|
39
|
+
res.statusCode = 504;
|
|
40
|
+
res.statusMessage = "Upstream timed out";
|
|
41
|
+
}
|
|
42
|
+
__name(populateAbortErrorResponse, "populateAbortErrorResponse");
|
|
43
|
+
|
|
44
|
+
// src/handlers/proxyRequests.ts
|
|
45
|
+
function proxyRequests(rest) {
|
|
46
|
+
return async (req, res) => {
|
|
47
|
+
const { method, url } = req;
|
|
48
|
+
if (!method || !url) {
|
|
49
|
+
throw new TypeError(
|
|
50
|
+
"Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const fullRoute = new URL(url, "http://noop").pathname.replace(/^\/api(\/v\d+)?/, "");
|
|
54
|
+
try {
|
|
55
|
+
const discordResponse = await rest.raw({
|
|
56
|
+
body: req,
|
|
57
|
+
fullRoute,
|
|
58
|
+
method,
|
|
59
|
+
passThroughBody: true,
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": req.headers["content-type"]
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
await populateSuccessfulResponse(res, discordResponse);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (error instanceof DiscordAPIError || error instanceof HTTPError) {
|
|
67
|
+
populateGeneralErrorResponse(res, error);
|
|
68
|
+
} else if (error instanceof RateLimitError) {
|
|
69
|
+
populateRatelimitErrorResponse(res, error);
|
|
70
|
+
} else if (error instanceof Error && error.name === "AbortError") {
|
|
71
|
+
populateAbortErrorResponse(res);
|
|
72
|
+
} else {
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
res.end();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
__name(proxyRequests, "proxyRequests");
|
|
81
|
+
export {
|
|
82
|
+
populateAbortErrorResponse,
|
|
83
|
+
populateGeneralErrorResponse,
|
|
84
|
+
populateRatelimitErrorResponse,
|
|
85
|
+
populateSuccessfulResponse,
|
|
86
|
+
proxyRequests
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/handlers/proxyRequests.ts","../src/util/responseHelpers.ts"],"sourcesContent":["import { URL } from 'node:url';\nimport {\n\tDiscordAPIError,\n\tHTTPError,\n\tRateLimitError,\n\ttype RequestMethod,\n\ttype REST,\n\ttype RouteLike,\n} from '@discordjs/rest';\nimport {\n\tpopulateAbortErrorResponse,\n\tpopulateGeneralErrorResponse,\n\tpopulateSuccessfulResponse,\n\tpopulateRatelimitErrorResponse,\n} from '../util/responseHelpers.js';\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\t// eslint-disable-next-line prefer-named-capture-group, unicorn/no-unsafe-regex\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","import type { ServerResponse } from 'node:http';\nimport { pipeline } from 'node:stream/promises';\nimport type { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';\nimport type { Dispatcher } from 'undici';\n\n/**\n * Populates a server response with the data from a Discord 2xx REST response\n *\n * @param res - The server response to populate\n * @param data - The data to populate the response with\n */\nexport async function populateSuccessfulResponse(res: ServerResponse, data: Dispatcher.ResponseData): Promise<void> {\n\tres.statusCode = data.statusCode;\n\n\tfor (const header of Object.keys(data.headers)) {\n\t\t// Strip ratelimit headers\n\t\tif (header.startsWith('x-ratelimit')) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tres.setHeader(header, data.headers[header]!);\n\t}\n\n\tawait pipeline(data.body, res);\n}\n\n/**\n * Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void {\n\tres.statusCode = error.status;\n\n\tif ('rawError' in error) {\n\t\tres.setHeader('Content-Type', 'application/json');\n\t\tres.write(JSON.stringify(error.rawError));\n\t}\n}\n\n/**\n * Populates a server response with the data from a Discord 429 REST response\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void {\n\tres.statusCode = 429;\n\tres.setHeader('Retry-After', error.timeToReset / 1_000);\n}\n\n/**\n * Populates a server response with data relevant for a timeout\n *\n * @param res - The sever response to populate\n */\nexport function populateAbortErrorResponse(res: ServerResponse): void {\n\tres.statusCode = 504;\n\tres.statusMessage = 'Upstream timed out';\n}\n"],"mappings":";;;;AAAA,SAAS,WAAW;AACpB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAIM;;;ACPP,SAAS,gBAAgB;AAUzB,eAAsB,2BAA2B,KAAqB,MAA8C;AACnH,MAAI,aAAa,KAAK;AAEtB,aAAW,UAAU,OAAO,KAAK,KAAK,OAAO,GAAG;AAE/C,QAAI,OAAO,WAAW,aAAa,GAAG;AACrC;AAAA,IACD;AAEA,QAAI,UAAU,QAAQ,KAAK,QAAQ,OAAQ;AAAA,EAC5C;AAEA,QAAM,SAAS,KAAK,MAAM,GAAG;AAC9B;AAbsB;AAqBf,SAAS,6BAA6B,KAAqB,OAA0C;AAC3G,MAAI,aAAa,MAAM;AAEvB,MAAI,cAAc,OAAO;AACxB,QAAI,UAAU,gBAAgB,kBAAkB;AAChD,QAAI,MAAM,KAAK,UAAU,MAAM,QAAQ,CAAC;AAAA,EACzC;AACD;AAPgB;AAeT,SAAS,+BAA+B,KAAqB,OAA6B;AAChG,MAAI,aAAa;AACjB,MAAI,UAAU,eAAe,MAAM,cAAc,GAAK;AACvD;AAHgB;AAUT,SAAS,2BAA2B,KAA2B;AACrE,MAAI,aAAa;AACjB,MAAI,gBAAgB;AACrB;AAHgB;;;ADnCT,SAAS,cAAc,MAA4B;AACzD,SAAO,OAAO,KAAK,QAAQ;AAC1B,UAAM,EAAE,QAAQ,IAAI,IAAI;AAExB,QAAI,CAAC,UAAU,CAAC,KAAK;AACpB,YAAM,IAAI;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAKA,UAAM,YAAY,IAAI,IAAI,KAAK,aAAa,EAAE,SAAS,QAAQ,mBAAmB,EAAE;AAEpF,QAAI;AACH,YAAM,kBAAkB,MAAM,KAAK,IAAI;AAAA,QACtC,MAAM;AAAA,QACN;AAAA,QAEA;AAAA,QACA,iBAAiB;AAAA,QACjB,SAAS;AAAA,UACR,gBAAgB,IAAI,QAAQ;AAAA,QAC7B;AAAA,MACD,CAAC;AAED,YAAM,2BAA2B,KAAK,eAAe;AAAA,IACtD,SAAS,OAAP;AACD,UAAI,iBAAiB,mBAAmB,iBAAiB,WAAW;AACnE,qCAA6B,KAAK,KAAK;AAAA,MACxC,WAAW,iBAAiB,gBAAgB;AAC3C,uCAA+B,KAAK,KAAK;AAAA,MAC1C,WAAW,iBAAiB,SAAS,MAAM,SAAS,cAAc;AACjE,mCAA2B,GAAG;AAAA,MAC/B,OAAO;AAGN,cAAM;AAAA,MACP;AAAA,IACD,UAAE;AACD,UAAI,IAAI;AAAA,IACT;AAAA,EACD;AACD;AA5CgB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordjs/proxy",
|
|
3
|
-
"version": "1.2.0-dev.
|
|
3
|
+
"version": "1.2.0-dev.1662250231-d08a57c.0",
|
|
4
4
|
"description": "Tools for running an HTTP proxy for Discord's API",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest run",
|
|
7
|
-
"build": "
|
|
7
|
+
"build": "tsup",
|
|
8
8
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
|
9
9
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
|
10
10
|
"fmt": "yarn format",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
|
|
14
14
|
"release": "cliff-jumper"
|
|
15
15
|
},
|
|
16
|
-
"main": "./dist/index.
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
17
|
"module": "./dist/index.mjs",
|
|
18
18
|
"typings": "./dist/index.d.ts",
|
|
19
19
|
"exports": {
|
|
20
20
|
"import": "./dist/index.mjs",
|
|
21
|
-
"require": "./dist/index.
|
|
21
|
+
"require": "./dist/index.js",
|
|
22
22
|
"types": "./dist/index.d.ts"
|
|
23
23
|
},
|
|
24
24
|
"directories": {
|
|
@@ -56,28 +56,22 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@discordjs/rest": "^1.0.0",
|
|
58
58
|
"tslib": "^2.4.0",
|
|
59
|
-
"undici": "^5.
|
|
59
|
+
"undici": "^5.10.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@discordjs/docgen": "^0.12.1",
|
|
63
63
|
"@favware/cliff-jumper": "^1.8.7",
|
|
64
|
-
"@microsoft/api-extractor": "^7.
|
|
65
|
-
"@types/node": "^16.11.
|
|
64
|
+
"@microsoft/api-extractor": "^7.30.0",
|
|
65
|
+
"@types/node": "^16.11.56",
|
|
66
66
|
"@types/supertest": "^2.0.12",
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
|
68
|
-
"@typescript-eslint/parser": "^5.34.0",
|
|
69
67
|
"@vitest/coverage-c8": "^0.22.1",
|
|
70
|
-
"downlevel-dts": "^0.10.
|
|
71
|
-
"eslint": "^8.
|
|
72
|
-
"eslint-config-
|
|
73
|
-
"eslint-config-prettier": "^8.5.0",
|
|
74
|
-
"eslint-import-resolver-typescript": "^3.5.0",
|
|
75
|
-
"eslint-plugin-import": "^2.26.0",
|
|
68
|
+
"downlevel-dts": "^0.10.1",
|
|
69
|
+
"eslint": "^8.23.0",
|
|
70
|
+
"eslint-config-neon": "^0.1.31",
|
|
76
71
|
"prettier": "^2.7.1",
|
|
77
|
-
"rollup-plugin-typescript2": "^0.33.0",
|
|
78
72
|
"supertest": "^6.2.4",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
73
|
+
"tsup": "^6.2.3",
|
|
74
|
+
"typescript": "^4.8.2",
|
|
81
75
|
"vitest": "^0.22.1"
|
|
82
76
|
},
|
|
83
77
|
"engines": {
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const node_url = require('node:url');
|
|
6
|
-
const rest = require('@discordjs/rest');
|
|
7
|
-
const responseHelpers = require('../util/responseHelpers.cjs');
|
|
8
|
-
|
|
9
|
-
function proxyRequests(rest$1) {
|
|
10
|
-
return async (req, res) => {
|
|
11
|
-
const { method, url } = req;
|
|
12
|
-
if (!method || !url) {
|
|
13
|
-
throw new TypeError(
|
|
14
|
-
"Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage"
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
const fullRoute = new node_url.URL(url, "http://noop").pathname.replace(/^\/api(\/v\d+)?/, "");
|
|
18
|
-
try {
|
|
19
|
-
const discordResponse = await rest$1.raw({
|
|
20
|
-
body: req,
|
|
21
|
-
fullRoute,
|
|
22
|
-
method,
|
|
23
|
-
passThroughBody: true,
|
|
24
|
-
headers: {
|
|
25
|
-
"Content-Type": req.headers["content-type"]
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
await responseHelpers.populateSuccessfulResponse(res, discordResponse);
|
|
29
|
-
} catch (error) {
|
|
30
|
-
if (error instanceof rest.DiscordAPIError || error instanceof rest.HTTPError) {
|
|
31
|
-
responseHelpers.populateGeneralErrorResponse(res, error);
|
|
32
|
-
} else if (error instanceof rest.RateLimitError) {
|
|
33
|
-
responseHelpers.populateRatelimitErrorResponse(res, error);
|
|
34
|
-
} else if (error instanceof Error && error.name === "AbortError") {
|
|
35
|
-
responseHelpers.populateAbortErrorResponse(res);
|
|
36
|
-
} else {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
} finally {
|
|
40
|
-
res.end();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.proxyRequests = proxyRequests;
|
|
46
|
-
//# sourceMappingURL=proxyRequests.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AACzB,QAAQ,gGAAgG;AACxG,OAAO,CAAC;AACR,KAAK;AACL,IAAI,MAAM,SAAS,GAAG,IAAIC,YAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAC1F,IAAI,IAAI;AACR,MAAM,MAAM,eAAe,GAAG,MAAMD,MAAI,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,MAAME,0CAA0B,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AAC7D,KAAK,CAAC,OAAO,KAAK,EAAE;AACpB,MAAM,IAAI,KAAK,YAAYC,oBAAe,IAAI,KAAK,YAAYC,cAAS,EAAE;AAC1E,QAAQC,4CAA4B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACjD,OAAO,MAAM,IAAI,KAAK,YAAYC,mBAAc,EAAE;AAClD,QAAQC,8CAA8B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACnD,OAAO,MAAM,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE;AACxE,QAAQC,0CAA0B,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;;;;"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { REST } from '@discordjs/rest';
|
|
2
|
-
import type { RequestHandler } from '../util/util';
|
|
3
|
-
/**
|
|
4
|
-
* Creates an HTTP handler used to forward requests to Discord
|
|
5
|
-
*
|
|
6
|
-
* @param rest - REST instance to use for the requests
|
|
7
|
-
*/
|
|
8
|
-
export declare function proxyRequests(rest: REST): RequestHandler;
|
|
9
|
-
//# sourceMappingURL=proxyRequests.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxyRequests.d.ts","sourceRoot":"","sources":["../../src/handlers/proxyRequests.ts"],"names":[],"mappings":"AACA,OAAO,EAA6D,IAAI,EAAa,MAAM,iBAAiB,CAAC;AAO7G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CA2CxD"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { URL } from 'node:url';
|
|
2
|
-
import { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';
|
|
3
|
-
import { populateSuccessfulResponse, populateGeneralErrorResponse, populateRatelimitErrorResponse, populateAbortErrorResponse } from '../util/responseHelpers.mjs';
|
|
4
|
-
|
|
5
|
-
function proxyRequests(rest) {
|
|
6
|
-
return async (req, res) => {
|
|
7
|
-
const { method, url } = req;
|
|
8
|
-
if (!method || !url) {
|
|
9
|
-
throw new TypeError(
|
|
10
|
-
"Invalid request. Missing method and/or url, implying that this is not a Server IncomingMessage"
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
const fullRoute = new URL(url, "http://noop").pathname.replace(/^\/api(\/v\d+)?/, "");
|
|
14
|
-
try {
|
|
15
|
-
const discordResponse = await rest.raw({
|
|
16
|
-
body: req,
|
|
17
|
-
fullRoute,
|
|
18
|
-
method,
|
|
19
|
-
passThroughBody: true,
|
|
20
|
-
headers: {
|
|
21
|
-
"Content-Type": req.headers["content-type"]
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
await populateSuccessfulResponse(res, discordResponse);
|
|
25
|
-
} catch (error) {
|
|
26
|
-
if (error instanceof DiscordAPIError || error instanceof HTTPError) {
|
|
27
|
-
populateGeneralErrorResponse(res, error);
|
|
28
|
-
} else if (error instanceof RateLimitError) {
|
|
29
|
-
populateRatelimitErrorResponse(res, error);
|
|
30
|
-
} else if (error instanceof Error && error.name === "AbortError") {
|
|
31
|
-
populateAbortErrorResponse(res);
|
|
32
|
-
} else {
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
} finally {
|
|
36
|
-
res.end();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { proxyRequests };
|
|
42
|
-
//# sourceMappingURL=proxyRequests.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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/dist/index.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const proxyRequests = require('./handlers/proxyRequests.cjs');
|
|
6
|
-
const responseHelpers = require('./util/responseHelpers.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.proxyRequests = proxyRequests.proxyRequests;
|
|
11
|
-
exports.populateAbortErrorResponse = responseHelpers.populateAbortErrorResponse;
|
|
12
|
-
exports.populateGeneralErrorResponse = responseHelpers.populateGeneralErrorResponse;
|
|
13
|
-
exports.populateRatelimitErrorResponse = responseHelpers.populateRatelimitErrorResponse;
|
|
14
|
-
exports.populateSuccessfulResponse = responseHelpers.populateSuccessfulResponse;
|
|
15
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const promises = require('node:stream/promises');
|
|
6
|
-
|
|
7
|
-
async function populateSuccessfulResponse(res, data) {
|
|
8
|
-
res.statusCode = data.statusCode;
|
|
9
|
-
for (const header of Object.keys(data.headers)) {
|
|
10
|
-
if (header.startsWith("x-ratelimit")) {
|
|
11
|
-
continue;
|
|
12
|
-
}
|
|
13
|
-
res.setHeader(header, data.headers[header]);
|
|
14
|
-
}
|
|
15
|
-
await promises.pipeline(data.body, res);
|
|
16
|
-
}
|
|
17
|
-
function populateGeneralErrorResponse(res, error) {
|
|
18
|
-
res.statusCode = error.status;
|
|
19
|
-
if ("rawError" in error) {
|
|
20
|
-
res.setHeader("Content-Type", "application/json");
|
|
21
|
-
res.write(JSON.stringify(error.rawError));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function populateRatelimitErrorResponse(res, error) {
|
|
25
|
-
res.statusCode = 429;
|
|
26
|
-
res.setHeader("Retry-After", error.timeToReset / 1e3);
|
|
27
|
-
}
|
|
28
|
-
function populateAbortErrorResponse(res) {
|
|
29
|
-
res.statusCode = 504;
|
|
30
|
-
res.statusMessage = "Upstream timed out";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.populateAbortErrorResponse = populateAbortErrorResponse;
|
|
34
|
-
exports.populateGeneralErrorResponse = populateGeneralErrorResponse;
|
|
35
|
-
exports.populateRatelimitErrorResponse = populateRatelimitErrorResponse;
|
|
36
|
-
exports.populateSuccessfulResponse = populateSuccessfulResponse;
|
|
37
|
-
//# sourceMappingURL=responseHelpers.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"responseHelpers.cjs","sources":["../../src/util/responseHelpers.ts"],"sourcesContent":["import type { ServerResponse } from 'node:http';\nimport { pipeline } from 'node:stream/promises';\nimport type { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';\nimport type { Dispatcher } from 'undici';\n\n/**\n * Populates a server response with the data from a Discord 2xx REST response\n *\n * @param res - The server response to populate\n * @param data - The data to populate the response with\n */\nexport async function populateSuccessfulResponse(res: ServerResponse, data: Dispatcher.ResponseData): Promise<void> {\n\tres.statusCode = data.statusCode;\n\n\tfor (const header of Object.keys(data.headers)) {\n\t\t// Strip ratelimit headers\n\t\tif (header.startsWith('x-ratelimit')) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tres.setHeader(header, data.headers[header]!);\n\t}\n\n\tawait pipeline(data.body, res);\n}\n\n/**\n * Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void {\n\tres.statusCode = error.status;\n\n\tif ('rawError' in error) {\n\t\tres.setHeader('Content-Type', 'application/json');\n\t\tres.write(JSON.stringify(error.rawError));\n\t}\n}\n\n/**\n * Populates a server response with the data from a Discord 429 REST response\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void {\n\tres.statusCode = 429;\n\tres.setHeader('Retry-After', error.timeToReset / 1000);\n}\n\n/**\n * Populates a server response with data relevant for a timeout\n *\n * @param res - The sever response to populate\n */\nexport function populateAbortErrorResponse(res: ServerResponse): void {\n\tres.statusCode = 504;\n\tres.statusMessage = 'Upstream timed out';\n}\n"],"names":["pipeline"],"mappings":";;;;;;AACO,eAAe,0BAA0B,CAAC,GAAG,EAAE,IAAI,EAAE;AAC5D,EAAE,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;AACnC,EAAE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;AAClD,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;AAC1C,MAAM,SAAS;AACf,KAAK;AACL,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAChD,GAAG;AACH,EAAE,MAAMA,iBAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AACM,SAAS,4BAA4B,CAAC,GAAG,EAAE,KAAK,EAAE;AACzD,EAAE,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;AAChC,EAAE,IAAI,UAAU,IAAI,KAAK,EAAE;AAC3B,IAAI,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;AACtD,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9C,GAAG;AACH,CAAC;AACM,SAAS,8BAA8B,CAAC,GAAG,EAAE,KAAK,EAAE;AAC3D,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;AACvB,EAAE,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;AACxD,CAAC;AACM,SAAS,0BAA0B,CAAC,GAAG,EAAE;AAChD,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;AACvB,EAAE,GAAG,CAAC,aAAa,GAAG,oBAAoB,CAAC;AAC3C;;;;;;;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { ServerResponse } from 'node:http';
|
|
3
|
-
import type { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';
|
|
4
|
-
import type { Dispatcher } from 'undici';
|
|
5
|
-
/**
|
|
6
|
-
* Populates a server response with the data from a Discord 2xx REST response
|
|
7
|
-
*
|
|
8
|
-
* @param res - The server response to populate
|
|
9
|
-
* @param data - The data to populate the response with
|
|
10
|
-
*/
|
|
11
|
-
export declare function populateSuccessfulResponse(res: ServerResponse, data: Dispatcher.ResponseData): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429
|
|
14
|
-
*
|
|
15
|
-
* @param res - The server response to populate
|
|
16
|
-
* @param error - The error to populate the response with
|
|
17
|
-
*/
|
|
18
|
-
export declare function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void;
|
|
19
|
-
/**
|
|
20
|
-
* Populates a server response with the data from a Discord 429 REST response
|
|
21
|
-
*
|
|
22
|
-
* @param res - The server response to populate
|
|
23
|
-
* @param error - The error to populate the response with
|
|
24
|
-
*/
|
|
25
|
-
export declare function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void;
|
|
26
|
-
/**
|
|
27
|
-
* Populates a server response with data relevant for a timeout
|
|
28
|
-
*
|
|
29
|
-
* @param res - The sever response to populate
|
|
30
|
-
*/
|
|
31
|
-
export declare function populateAbortErrorResponse(res: ServerResponse): void;
|
|
32
|
-
//# sourceMappingURL=responseHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"responseHelpers.d.ts","sourceRoot":"","sources":["../../src/util/responseHelpers.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAalH;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAO1G;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAG/F;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAGpE"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { pipeline } from 'node:stream/promises';
|
|
2
|
-
|
|
3
|
-
async function populateSuccessfulResponse(res, data) {
|
|
4
|
-
res.statusCode = data.statusCode;
|
|
5
|
-
for (const header of Object.keys(data.headers)) {
|
|
6
|
-
if (header.startsWith("x-ratelimit")) {
|
|
7
|
-
continue;
|
|
8
|
-
}
|
|
9
|
-
res.setHeader(header, data.headers[header]);
|
|
10
|
-
}
|
|
11
|
-
await pipeline(data.body, res);
|
|
12
|
-
}
|
|
13
|
-
function populateGeneralErrorResponse(res, error) {
|
|
14
|
-
res.statusCode = error.status;
|
|
15
|
-
if ("rawError" in error) {
|
|
16
|
-
res.setHeader("Content-Type", "application/json");
|
|
17
|
-
res.write(JSON.stringify(error.rawError));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function populateRatelimitErrorResponse(res, error) {
|
|
21
|
-
res.statusCode = 429;
|
|
22
|
-
res.setHeader("Retry-After", error.timeToReset / 1e3);
|
|
23
|
-
}
|
|
24
|
-
function populateAbortErrorResponse(res) {
|
|
25
|
-
res.statusCode = 504;
|
|
26
|
-
res.statusMessage = "Upstream timed out";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { populateAbortErrorResponse, populateGeneralErrorResponse, populateRatelimitErrorResponse, populateSuccessfulResponse };
|
|
30
|
-
//# sourceMappingURL=responseHelpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"responseHelpers.mjs","sources":["../../src/util/responseHelpers.ts"],"sourcesContent":["import type { ServerResponse } from 'node:http';\nimport { pipeline } from 'node:stream/promises';\nimport type { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';\nimport type { Dispatcher } from 'undici';\n\n/**\n * Populates a server response with the data from a Discord 2xx REST response\n *\n * @param res - The server response to populate\n * @param data - The data to populate the response with\n */\nexport async function populateSuccessfulResponse(res: ServerResponse, data: Dispatcher.ResponseData): Promise<void> {\n\tres.statusCode = data.statusCode;\n\n\tfor (const header of Object.keys(data.headers)) {\n\t\t// Strip ratelimit headers\n\t\tif (header.startsWith('x-ratelimit')) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tres.setHeader(header, data.headers[header]!);\n\t}\n\n\tawait pipeline(data.body, res);\n}\n\n/**\n * Populates a server response with the data from a Discord non-2xx REST response that is NOT a 429\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void {\n\tres.statusCode = error.status;\n\n\tif ('rawError' in error) {\n\t\tres.setHeader('Content-Type', 'application/json');\n\t\tres.write(JSON.stringify(error.rawError));\n\t}\n}\n\n/**\n * Populates a server response with the data from a Discord 429 REST response\n *\n * @param res - The server response to populate\n * @param error - The error to populate the response with\n */\nexport function populateRatelimitErrorResponse(res: ServerResponse, error: RateLimitError): void {\n\tres.statusCode = 429;\n\tres.setHeader('Retry-After', error.timeToReset / 1000);\n}\n\n/**\n * Populates a server response with data relevant for a timeout\n *\n * @param res - The sever response to populate\n */\nexport function populateAbortErrorResponse(res: ServerResponse): void {\n\tres.statusCode = 504;\n\tres.statusMessage = 'Upstream timed out';\n}\n"],"names":[],"mappings":";;AACO,eAAe,0BAA0B,CAAC,GAAG,EAAE,IAAI,EAAE;AAC5D,EAAE,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;AACnC,EAAE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;AAClD,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;AAC1C,MAAM,SAAS;AACf,KAAK;AACL,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAChD,GAAG;AACH,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AACM,SAAS,4BAA4B,CAAC,GAAG,EAAE,KAAK,EAAE;AACzD,EAAE,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;AAChC,EAAE,IAAI,UAAU,IAAI,KAAK,EAAE;AAC3B,IAAI,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;AACtD,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9C,GAAG;AACH,CAAC;AACM,SAAS,8BAA8B,CAAC,GAAG,EAAE,KAAK,EAAE;AAC3D,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;AACvB,EAAE,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;AACxD,CAAC;AACM,SAAS,0BAA0B,CAAC,GAAG,EAAE;AAChD,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;AACvB,EAAE,GAAG,CAAC,aAAa,GAAG,oBAAoB,CAAC;AAC3C;;;;"}
|
package/dist/util/util.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a potentially awaitable value
|
|
5
|
-
*/
|
|
6
|
-
export declare type Awaitable<T> = T | PromiseLike<T>;
|
|
7
|
-
/**
|
|
8
|
-
* Represents a simple HTTP request handler
|
|
9
|
-
*/
|
|
10
|
-
export declare type RequestHandler = (req: IncomingMessage, res: ServerResponse) => Awaitable<void>;
|
|
11
|
-
//# sourceMappingURL=util.d.ts.map
|
package/dist/util/util.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util/util.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE;;GAEG;AACH,oBAAY,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAE9C;;GAEG;AACH,oBAAY,cAAc,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC"}
|