mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-06 09:26:55 +00:00
Chore: move to eslint (#6270)
This commit is contained in:
parent
1233b5e803
commit
97e909ebf4
@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"next/core-web-vitals",
|
|
||||||
"prettier",
|
|
||||||
"plugin:react-hooks/recommended"
|
|
||||||
],
|
|
||||||
"plugins": ["prettier"],
|
|
||||||
"rules": {
|
|
||||||
"import/no-cycle": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"maxDepth": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"import/order": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"newlines-between": "always"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-else-return": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"allowElseIf": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"settings": {
|
|
||||||
"import/resolver": {
|
|
||||||
"node": {
|
|
||||||
"paths": ["src"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 6,
|
|
||||||
"sourceType": "module",
|
|
||||||
"ecmaFeatures": {
|
|
||||||
"modules": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
69
eslint.config.mjs
Normal file
69
eslint.config.mjs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import path from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
import { fixupConfigRules } from "@eslint/compat";
|
||||||
|
import { FlatCompat } from "@eslint/eslintrc";
|
||||||
|
import js from "@eslint/js";
|
||||||
|
import prettier from "eslint-plugin-prettier";
|
||||||
|
import { defineConfig, globalIgnores } from "eslint/config";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default defineConfig([
|
||||||
|
{
|
||||||
|
extends: fixupConfigRules(compat.extends("next/core-web-vitals", "prettier", "plugin:react-hooks/recommended")),
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
prettier,
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 6,
|
||||||
|
sourceType: "module",
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: {
|
||||||
|
modules: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
"import/resolver": {
|
||||||
|
node: {
|
||||||
|
paths: ["src"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
"import/no-cycle": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
maxDepth: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"import/order": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"newlines-between": "always",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
"no-else-return": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
allowElseIf: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
globalIgnores(["./config/", "./.venv/", "./.next/", "./site/"]),
|
||||||
|
]);
|
||||||
@ -1,6 +1,5 @@
|
|||||||
// prettyBytes taken from https://github.com/sindresorhus/pretty-bytes
|
// prettyBytes taken from https://github.com/sindresorhus/pretty-bytes
|
||||||
|
|
||||||
/* eslint-disable no-param-reassign */
|
|
||||||
const BYTE_UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
const BYTE_UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
|
|
||||||
const BIBYTE_UNITS = ["B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
const BIBYTE_UNITS = ["B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
||||||
@ -37,7 +36,6 @@ function prettyBytes(number, options) {
|
|||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line no-nested-ternary
|
|
||||||
const UNITS = options.bits ? (options.binary ? BIBIT_UNITS : BIT_UNITS) : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
const UNITS = options.bits ? (options.binary ? BIBIT_UNITS : BIT_UNITS) : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
||||||
|
|
||||||
if (options.signed && number === 0) {
|
if (options.signed && number === 0) {
|
||||||
@ -45,7 +43,7 @@ function prettyBytes(number, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isNegative = number < 0;
|
const isNegative = number < 0;
|
||||||
// eslint-disable-next-line no-nested-ternary
|
|
||||||
const prefix = isNegative ? "-" : options.signed ? "+" : "";
|
const prefix = isNegative ? "-" : options.signed ? "+" : "";
|
||||||
|
|
||||||
if (isNegative) {
|
if (isNegative) {
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "eslint .",
|
||||||
"telemetry": "next telemetry disable"
|
"telemetry": "next telemetry disable"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -44,6 +44,9 @@
|
|||||||
"xml-js": "^1.6.11"
|
"xml-js": "^1.6.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/compat": "^2.0.2",
|
||||||
|
"@eslint/eslintrc": "^3.3.3",
|
||||||
|
"@eslint/js": "^9.39.2",
|
||||||
"@tailwindcss/forms": "^0.5.10",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/postcss": "^4.1.18",
|
"@tailwindcss/postcss": "^4.1.18",
|
||||||
"eslint": "^9.25.1",
|
"eslint": "^9.25.1",
|
||||||
|
|||||||
@ -102,6 +102,15 @@ importers:
|
|||||||
specifier: ^1.6.11
|
specifier: ^1.6.11
|
||||||
version: 1.6.11
|
version: 1.6.11
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
'@eslint/compat':
|
||||||
|
specifier: ^2.0.2
|
||||||
|
version: 2.0.2(eslint@9.25.1(jiti@2.6.1))
|
||||||
|
'@eslint/eslintrc':
|
||||||
|
specifier: ^3.3.3
|
||||||
|
version: 3.3.3
|
||||||
|
'@eslint/js':
|
||||||
|
specifier: ^9.39.2
|
||||||
|
version: 9.39.2
|
||||||
'@tailwindcss/forms':
|
'@tailwindcss/forms':
|
||||||
specifier: ^0.5.10
|
specifier: ^0.5.10
|
||||||
version: 0.5.10(tailwindcss@4.1.18)
|
version: 0.5.10(tailwindcss@4.1.18)
|
||||||
@ -202,6 +211,15 @@ packages:
|
|||||||
resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==}
|
resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==}
|
||||||
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
|
engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}
|
||||||
|
|
||||||
|
'@eslint/compat@2.0.2':
|
||||||
|
resolution: {integrity: sha512-pR1DoD0h3HfF675QZx0xsyrsU8q70Z/plx7880NOhS02NuWLgBCOMDL787nUeQ7EWLkxv3bPQJaarjcPQb2Dwg==}
|
||||||
|
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
|
||||||
|
peerDependencies:
|
||||||
|
eslint: ^8.40 || 9 || 10
|
||||||
|
peerDependenciesMeta:
|
||||||
|
eslint:
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@eslint/config-array@0.20.0':
|
'@eslint/config-array@0.20.0':
|
||||||
resolution: {integrity: sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==}
|
resolution: {integrity: sha512-fxlS1kkIjx8+vy2SjuCB94q3htSNrufYTXubwiBFeaQHbH6Ipi43gFJq2zCMt6PHhImH3Xmr0NksKDvchWlpQQ==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@ -214,14 +232,22 @@ packages:
|
|||||||
resolution: {integrity: sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==}
|
resolution: {integrity: sha512-yfkgDw1KR66rkT5A8ci4irzDysN7FRpq3ttJolR88OqQikAWqwA8j5VZyas+vjyBNFIJ7MfybJ9plMILI2UrCw==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@eslint/eslintrc@3.3.1':
|
'@eslint/core@1.1.0':
|
||||||
resolution: {integrity: sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==}
|
resolution: {integrity: sha512-/nr9K9wkr3P1EzFTdFdMoLuo1PmIxjmwvPozwoSodjNBdefGujXQUF93u1DDZpEaTuDvMsIQddsd35BwtrW9Xw==}
|
||||||
|
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
|
||||||
|
|
||||||
|
'@eslint/eslintrc@3.3.3':
|
||||||
|
resolution: {integrity: sha512-Kr+LPIUVKz2qkx1HAMH8q1q6azbqBAsXJUxBl/ODDuVPX45Z9DfwB8tPjTi6nNZ8BuM3nbJxC5zCAg5elnBUTQ==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@eslint/js@9.25.1':
|
'@eslint/js@9.25.1':
|
||||||
resolution: {integrity: sha512-dEIwmjntEx8u3Uvv+kr3PDeeArL8Hw07H9kyYxCjnM9pBjfEhk6uLXSchxxzgiwtRhhzVzqmUSDFBOi1TuZ7qg==}
|
resolution: {integrity: sha512-dEIwmjntEx8u3Uvv+kr3PDeeArL8Hw07H9kyYxCjnM9pBjfEhk6uLXSchxxzgiwtRhhzVzqmUSDFBOi1TuZ7qg==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
|
'@eslint/js@9.39.2':
|
||||||
|
resolution: {integrity: sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==}
|
||||||
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
|
|
||||||
'@eslint/object-schema@2.1.6':
|
'@eslint/object-schema@2.1.6':
|
||||||
resolution: {integrity: sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==}
|
resolution: {integrity: sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==}
|
||||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||||
@ -3099,6 +3125,12 @@ snapshots:
|
|||||||
|
|
||||||
'@eslint-community/regexpp@4.12.1': {}
|
'@eslint-community/regexpp@4.12.1': {}
|
||||||
|
|
||||||
|
'@eslint/compat@2.0.2(eslint@9.25.1(jiti@2.6.1))':
|
||||||
|
dependencies:
|
||||||
|
'@eslint/core': 1.1.0
|
||||||
|
optionalDependencies:
|
||||||
|
eslint: 9.25.1(jiti@2.6.1)
|
||||||
|
|
||||||
'@eslint/config-array@0.20.0':
|
'@eslint/config-array@0.20.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@eslint/object-schema': 2.1.6
|
'@eslint/object-schema': 2.1.6
|
||||||
@ -3113,10 +3145,14 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@types/json-schema': 7.0.15
|
'@types/json-schema': 7.0.15
|
||||||
|
|
||||||
'@eslint/eslintrc@3.3.1':
|
'@eslint/core@1.1.0':
|
||||||
|
dependencies:
|
||||||
|
'@types/json-schema': 7.0.15
|
||||||
|
|
||||||
|
'@eslint/eslintrc@3.3.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
ajv: 6.12.6
|
ajv: 6.12.6
|
||||||
debug: 4.4.0
|
debug: 4.4.1
|
||||||
espree: 10.3.0
|
espree: 10.3.0
|
||||||
globals: 14.0.0
|
globals: 14.0.0
|
||||||
ignore: 5.3.2
|
ignore: 5.3.2
|
||||||
@ -3129,6 +3165,8 @@ snapshots:
|
|||||||
|
|
||||||
'@eslint/js@9.25.1': {}
|
'@eslint/js@9.25.1': {}
|
||||||
|
|
||||||
|
'@eslint/js@9.39.2': {}
|
||||||
|
|
||||||
'@eslint/object-schema@2.1.6': {}
|
'@eslint/object-schema@2.1.6': {}
|
||||||
|
|
||||||
'@eslint/plugin-kit@0.2.8':
|
'@eslint/plugin-kit@0.2.8':
|
||||||
@ -4559,7 +4597,7 @@ snapshots:
|
|||||||
'@eslint/config-array': 0.20.0
|
'@eslint/config-array': 0.20.0
|
||||||
'@eslint/config-helpers': 0.2.2
|
'@eslint/config-helpers': 0.2.2
|
||||||
'@eslint/core': 0.13.0
|
'@eslint/core': 0.13.0
|
||||||
'@eslint/eslintrc': 3.3.1
|
'@eslint/eslintrc': 3.3.3
|
||||||
'@eslint/js': 9.25.1
|
'@eslint/js': 9.25.1
|
||||||
'@eslint/plugin-kit': 0.2.8
|
'@eslint/plugin-kit': 0.2.8
|
||||||
'@humanfs/node': 0.16.6
|
'@humanfs/node': 0.16.6
|
||||||
|
|||||||
@ -10,7 +10,6 @@ export function middleware(req) {
|
|||||||
allowedHosts = allowedHosts.concat(process.env.HOMEPAGE_ALLOWED_HOSTS.split(","));
|
allowedHosts = allowedHosts.concat(process.env.HOMEPAGE_ALLOWED_HOSTS.split(","));
|
||||||
}
|
}
|
||||||
if (!allowAll && (!host || !allowedHosts.includes(host))) {
|
if (!allowAll && (!host || !allowedHosts.includes(host))) {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error(
|
console.error(
|
||||||
`Host validation failed for: ${host}. Hint: Set the HOMEPAGE_ALLOWED_HOSTS environment variable to allow requests from this host / port.`,
|
`Host validation failed for: ${host}. Hint: Set the HOMEPAGE_ALLOWED_HOSTS environment variable to allow requests from this host / port.`,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -28,9 +28,7 @@ export default async function handler(req, res) {
|
|||||||
try {
|
try {
|
||||||
// maintain backwards compatibility with old ping where may be http://...
|
// maintain backwards compatibility with old ping where may be http://...
|
||||||
hostname = new URL(pingHostOrURL).hostname;
|
hostname = new URL(pingHostOrURL).hostname;
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
// eslint-disable-line no-empty
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await ping.probe(hostname);
|
const response = await ping.probe(hostname);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
@ -100,7 +99,6 @@ function convertLayoutGroupToGroup(name, layoutGroup) {
|
|||||||
function mergeSubgroups(configuredGroups, mergedGroup) {
|
function mergeSubgroups(configuredGroups, mergedGroup) {
|
||||||
configuredGroups.forEach((group) => {
|
configuredGroups.forEach((group) => {
|
||||||
if (group.name === mergedGroup.name) {
|
if (group.name === mergedGroup.name) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
group.services = mergedGroup.services;
|
group.services = mergedGroup.services;
|
||||||
} else if (group.groups) {
|
} else if (group.groups) {
|
||||||
mergeSubgroups(group.groups, mergedGroup);
|
mergeSubgroups(group.groups, mergedGroup);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Code primarely based on shvl repository: https://github.com/robinvdvleuten/shvl
|
Code primarely based on shvl repository: https://github.com/robinvdvleuten/shvl
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// eslint-disable-next-line import/prefer-default-export
|
|
||||||
export const columnMap = [
|
export const columnMap = [
|
||||||
"grid-cols-1 md:grid-cols-1 lg:grid-cols-1",
|
"grid-cols-1 md:grid-cols-1 lg:grid-cols-1",
|
||||||
"grid-cols-1 md:grid-cols-1 lg:grid-cols-1",
|
"grid-cols-1 md:grid-cols-1 lg:grid-cols-1",
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import { format as utilFormat } from "node:util";
|
import { format as utilFormat } from "node:util";
|
||||||
|
|
||||||
import winston from "winston";
|
import winston from "winston";
|
||||||
@ -9,10 +8,9 @@ let winstonLogger;
|
|||||||
|
|
||||||
function combineMessageAndSplat() {
|
function combineMessageAndSplat() {
|
||||||
return {
|
return {
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
transform: (info, opts) => {
|
transform: (info, opts) => {
|
||||||
// combine message and args if any
|
// combine message and args if any
|
||||||
// eslint-disable-next-line no-param-reassign
|
|
||||||
info.message = utilFormat(info.message, ...(info[Symbol.for("splat")] || []));
|
info.message = utilFormat(info.message, ...(info[Symbol.for("splat")] || []));
|
||||||
return info;
|
return info;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-param-reassign */
|
|
||||||
import { Cookie, CookieJar } from "tough-cookie";
|
import { Cookie, CookieJar } from "tough-cookie";
|
||||||
|
|
||||||
const cookieJar = new CookieJar();
|
const cookieJar = new CookieJar();
|
||||||
|
|||||||
@ -30,7 +30,6 @@ export async function sendJsonRpcRequest(url, method, params, widget) {
|
|||||||
body,
|
body,
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data] = await httpProxy(url, httpRequestParams);
|
const [status, contentType, data] = await httpProxy(url, httpRequestParams);
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
const json = JSON.parse(data.toString());
|
const json = JSON.parse(data.toString());
|
||||||
|
|||||||
@ -48,7 +48,7 @@ async function getApiInfo(serviceWidget, apiName, serviceName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const infoUrl = formatApiCall(INFO_ENDPOINT, serviceWidget);
|
const infoUrl = formatApiCall(INFO_ENDPOINT, serviceWidget);
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data] = await httpProxy(infoUrl);
|
const [status, contentType, data] = await httpProxy(infoUrl);
|
||||||
|
|
||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
@ -74,7 +74,6 @@ async function getApiInfo(serviceWidget, apiName, serviceName) {
|
|||||||
async function handleUnsuccessfulResponse(serviceWidget, url, serviceName) {
|
async function handleUnsuccessfulResponse(serviceWidget, url, serviceName) {
|
||||||
logger.debug(`Attempting login to ${serviceWidget.type}`);
|
logger.debug(`Attempting login to ${serviceWidget.type}`);
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [apiPath, maxVersion] = await getApiInfo(serviceWidget, AUTH_API_NAME, serviceName);
|
const [apiPath, maxVersion] = await getApiInfo(serviceWidget, AUTH_API_NAME, serviceName);
|
||||||
|
|
||||||
const authArgs = { path: apiPath ?? "entry.cgi", maxVersion: maxVersion ?? 7, ...serviceWidget };
|
const authArgs = { path: apiPath ?? "entry.cgi", maxVersion: maxVersion ?? 7, ...serviceWidget };
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
/* eslint-disable prefer-promise-reject-errors */
|
|
||||||
/* eslint-disable no-param-reassign */
|
|
||||||
import { createUnzip, constants as zlibConstants } from "node:zlib";
|
import { createUnzip, constants as zlibConstants } from "node:zlib";
|
||||||
|
|
||||||
import { http, https } from "follow-redirects";
|
import { http, https } from "follow-redirects";
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,6 @@ export default async function beszelProxyHandler(req, res) {
|
|||||||
return res.status(status).send(data);
|
return res.status(status).send(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
[status, , data] = await httpProxy(url, {
|
[status, , data] = await httpProxy(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -65,7 +65,6 @@ export default async function delugeProxyHandler(req, res) {
|
|||||||
return res.status(status).end(data);
|
return res.status(status).end(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
[status, contentType, data] = await sendRpc(url, dataMethod, dataParams);
|
[status, contentType, data] = await sendRpc(url, dataMethod, dataParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,6 @@ export default async function dispatcharrProxyHandler(req, res) {
|
|||||||
return res.status(status).send(data);
|
return res.status(status).send(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
[status, , data] = await httpProxy(url, {
|
[status, , data] = await httpProxy(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -22,7 +22,6 @@ async function login(widget) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
||||||
return [status, data];
|
return [status, data];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ async function login(widget, service) {
|
|||||||
const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget }));
|
const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget }));
|
||||||
const loginBody = { username: widget.username.toString(), password: widget.password.toString() };
|
const loginBody = { username: widget.username.toString(), password: widget.password.toString() };
|
||||||
const headers = { "Content-Type": "application/json" };
|
const headers = { "Content-Type": "application/json" };
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data, responseHeaders] = await httpProxy(loginUrl, {
|
const [status, contentType, data, responseHeaders] = await httpProxy(loginUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(loginBody),
|
body: JSON.stringify(loginBody),
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import querystring from "querystring";
|
import querystring from "querystring";
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,6 @@ export default async function npmProxyHandler(req, res) {
|
|||||||
return res.status(status).send(data);
|
return res.status(status).send(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
[status, , data] = await httpProxy(url, {
|
[status, , data] = await httpProxy(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -20,7 +20,6 @@ async function login(loginUrl, username, password, controllerVersionMajor) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data] = await httpProxy(loginUrl, {
|
const [status, contentType, data] = await httpProxy(loginUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(params),
|
body: JSON.stringify(params),
|
||||||
@ -234,7 +233,6 @@ export default async function omadaProxyHandler(req, res) {
|
|||||||
? `${url}/api/v2/sites/${siteName}/alerts/num?token=${token}¤tPage=1¤tPageSize=1000`
|
? `${url}/api/v2/sites/${siteName}/alerts/num?token=${token}¤tPage=1¤tPageSize=1000`
|
||||||
: `${url}/${cId}/api/v2/sites/${siteName}/alerts/num?token=${token}¤tPage=1¤tPageSize=1000`;
|
: `${url}/${cId}/api/v2/sites/${siteName}/alerts/num?token=${token}¤tPage=1¤tPageSize=1000`;
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
[status, contentType, data] = await httpProxy(alertUrl, {
|
[status, contentType, data] = await httpProxy(alertUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
"Csrf-Token": token,
|
"Csrf-Token": token,
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
|
||||||
import cache from "memory-cache";
|
import cache from "memory-cache";
|
||||||
import { xml2json } from "xml-js";
|
import { xml2json } from "xml-js";
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,6 @@ async function fetchFromPyloadAPI(url, sessionId, params, service) {
|
|||||||
options.headers.Cookie = cache.get(`${sessionCacheKey}.${service}`);
|
options.headers.Cookie = cache.get(`${sessionCacheKey}.${service}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data, responseHeaders] = await httpProxy(url, options);
|
const [status, contentType, data, responseHeaders] = await httpProxy(url, options);
|
||||||
const returnData = parsePyloadResponse(url, data);
|
const returnData = parsePyloadResponse(url, data);
|
||||||
return [status, returnData, responseHeaders];
|
return [status, returnData, responseHeaders];
|
||||||
@ -66,7 +65,6 @@ async function fetchFromPyloadAPIBasic(url, params, username, password) {
|
|||||||
options.body = JSON.stringify(params);
|
options.body = JSON.stringify(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data, responseHeaders] = await httpProxy(parsedUrl, options);
|
const [status, contentType, data, responseHeaders] = await httpProxy(parsedUrl, options);
|
||||||
const returnData = parsePyloadResponse(parsedUrl, data);
|
const returnData = parsePyloadResponse(parsedUrl, data);
|
||||||
return [status, returnData, responseHeaders];
|
return [status, returnData, responseHeaders];
|
||||||
|
|||||||
@ -15,7 +15,6 @@ async function login(widget) {
|
|||||||
body: loginBody,
|
body: loginBody,
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
const [status, contentType, data] = await httpProxy(loginUrl, loginParams);
|
||||||
return [status, data];
|
return [status, data];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,6 @@ export default async function xteveProxyHandler(req, res) {
|
|||||||
const payload = { cmd: "status" };
|
const payload = { cmd: "status" };
|
||||||
|
|
||||||
if (widget.username && widget.password) {
|
if (widget.username && widget.password) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
const [status, contentType, data] = await httpProxy(url, {
|
const [status, contentType, data] = await httpProxy(url, {
|
||||||
method,
|
method,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user