From 9b15787f119350ba00df9a44a381af2e8ad8a90d Mon Sep 17 00:00:00 2001 From: Robonau <30987265+Robonau@users.noreply.github> Date: Mon, 11 Nov 2024 20:31:20 +0000 Subject: [PATCH] better typing --- src/widgets/suwayomi/proxy.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/widgets/suwayomi/proxy.js b/src/widgets/suwayomi/proxy.js index f982bbaeb..274735227 100644 --- a/src/widgets/suwayomi/proxy.js +++ b/src/widgets/suwayomi/proxy.js @@ -172,6 +172,10 @@ function extractCounts(responseJSON, fields) { })); } +/** + * @param {string[]} Fields + * @returns {string[]} + */ function makeFields(Fields) { let fields = Fields; if (fields.length === 0) { @@ -183,6 +187,19 @@ function makeFields(Fields) { return fields; } +/** + * @typedef {object} widget + * @property {string} username + * @property {string} password + * @property {string[]} fields + * @property {string|number|undefined} category + * @property {keyof typeof widgets} type + */ + +/** + * @param {widget} widget + * @returns {{ "Content-Type": string, Authorization?: string }} + */ function makeHeaders(widget) { const headers = { "Content-Type": "application/json", @@ -202,7 +219,7 @@ export default async function suwayomiProxyHandler(req, res) { return res.status(400).json({ error: "Invalid proxy service type" }); } - /** @type {{ fields: string[],category: string|number|undefined, type: keyof typeof widgets }} */ + /** @type {widget} */ const widget = await getServiceWidget(group, service); if (!widget) {