mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
Fix bad typings left over from the migration
This commit is contained in:
1 parent
7314dc99c8
commit
80e1904175
22 files changed
+93
-117
No files matched your search
@@ -29,17 +29,13 @@ export default class ControlConnection extends BaseConnection {
|
||||
private _agent: string;
|
||||
private _version: string;
|
||||
logTransport: lib.LinkTransport | null = null;
|
||||
logSubscriptions: {
|
||||
all: boolean,
|
||||
controller: boolean,
|
||||
hostIds: number[],
|
||||
instanceIds: number[],
|
||||
} = {
|
||||
logSubscriptions = {
|
||||
all: false,
|
||||
controller: false,
|
||||
hostIds: [],
|
||||
instanceIds: [],
|
||||
hostIds: [] as number[],
|
||||
instanceIds: [] as number[],
|
||||
};
|
||||
|
||||
ws_dumper: ((...args: any[]) => void) | null = null;
|
||||
declare connector: WsServerConnector;
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import type winston from "winston";
|
||||
import type { AddressInfo } from "net";
|
||||
import type { ControllerArgs } from "../controller";
|
||||
import type { HostInfo } from "./HostConnection";
|
||||
import type { Request, Response, Application } from "express";
|
||||
|
||||
import express, { type Request, type Response, type NextFunction, type Application } from "express";
|
||||
|
||||
import compression from "compression";
|
||||
import events, { EventEmitter } from "events";
|
||||
import express from "express";
|
||||
import fs from "fs-extra";
|
||||
import http from "http";
|
||||
import https from "https";
|
||||
@@ -20,12 +17,11 @@ const { logger, Summary, Gauge } = lib;
|
||||
|
||||
import HttpCloser from "./HttpCloser";
|
||||
import InstanceInfo, { InstanceStatus } from "./InstanceInfo";
|
||||
import metrics from "./metrics";
|
||||
import * as metrics from "./metrics";
|
||||
import * as routes from "./routes";
|
||||
import UserManager from "./UserManager";
|
||||
import WsServer from "./WsServer";
|
||||
import yargs from "yargs";
|
||||
import HostConnection from "./HostConnection";
|
||||
import HostConnection, { type HostInfo } from "./HostConnection";
|
||||
|
||||
const endpointDurationSummary = new Summary(
|
||||
"clusterio_controller_http_endpoint_duration_seconds",
|
||||
@@ -176,7 +172,8 @@ export default class Controller {
|
||||
const webpackConfigs = [];
|
||||
|
||||
if (args.dev) {
|
||||
webpackConfigs.push(require("../../../webpack.config")({}));
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
webpackConfigs.push(require("../../../webpack.config")({})); // Path outside of build
|
||||
}
|
||||
if (args.devPlugin) {
|
||||
let devPlugins = new Map();
|
||||
@@ -882,8 +879,7 @@ export default class Controller {
|
||||
ControllerPluginClass = await lib.loadControllerPluginClass(pluginInfo);
|
||||
}
|
||||
|
||||
//@ts-ignore //TODO::: metrics is lib.Counter but ControllerPluginClass expect any[], can't figure out how the metrics is used.
|
||||
let controllerPlugin = new ControllerPluginClass(pluginInfo, this, metrics, logger);
|
||||
let controllerPlugin = new ControllerPluginClass(pluginInfo, this, metrics as any, logger);
|
||||
await controllerPlugin.init();
|
||||
this.plugins.set(pluginInfo.name, controllerPlugin);
|
||||
|
||||
@@ -950,8 +946,8 @@ export default class Controller {
|
||||
/**
|
||||
* Servers the web interface with the root path set apropriately
|
||||
*
|
||||
* @param {string} route - route the interface is served under.
|
||||
* @returns {function} Experess.js route handler.
|
||||
* @param route - route the interface is served under.
|
||||
* @returns Experess.js route handler.
|
||||
*/
|
||||
static serveWeb(route: string) {
|
||||
// The depth is is the number of slashes in the route minus one, but due
|
||||
@@ -959,7 +955,7 @@ export default class Controller {
|
||||
// compensate if the request path contains a slash but not the route,
|
||||
// and vice versa.
|
||||
let routeDepth = (route.match(/\//g) || []).length - 1 - Number(route.slice(-1) === "/");
|
||||
return function(req: Request, res: Response, next: Function) {
|
||||
return function(req: Request, res: Response, next: NextFunction) {
|
||||
let depth = routeDepth + Number(req.path.slice(-1) === "/");
|
||||
let webRoot = "../".repeat(depth) || "./";
|
||||
let staticRoot = webRoot;
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface HostInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
version: string;
|
||||
plugins: [number, any][];
|
||||
plugins: Record<string, string>;
|
||||
public_address: string | undefined;
|
||||
token_valid_after?: number;
|
||||
}
|
||||
@@ -30,10 +30,10 @@ export default class HostConnection extends BaseConnection {
|
||||
private _id: any;
|
||||
private _name: any;
|
||||
private _version: any;
|
||||
plugins: Map<string, Object>;
|
||||
plugins: Map<string, string>;
|
||||
|
||||
constructor(
|
||||
registerData: any,
|
||||
registerData: lib.RegisterHostData,
|
||||
connector: WsServerConnector,
|
||||
controller: Controller,
|
||||
) {
|
||||
|
||||
@@ -36,7 +36,7 @@ export default class InstanceInfo {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
toJSON(): Object {
|
||||
toJSON() {
|
||||
return {
|
||||
config: this.config.serialize(),
|
||||
status: this.status,
|
||||
|
||||
@@ -12,7 +12,7 @@ import ControlConnection from "./ControlConnection";
|
||||
import HostConnection, { HostInfo } from "./HostConnection";
|
||||
import WsServerConnector from "./WsServerConnector";
|
||||
|
||||
const packageVersion = require("../package.json").version;
|
||||
import { version as packageVersion } from "../package.json";
|
||||
|
||||
const wsMessageCounter = new lib.Counter(
|
||||
"clusterio_controller_websocket_message_total",
|
||||
@@ -111,12 +111,11 @@ export default class WsServer {
|
||||
}
|
||||
});
|
||||
let originalSend = socket.send;
|
||||
socket.send = (...args: any[]) => {
|
||||
socket.send = (...args: [string, any]) => {
|
||||
wsMessageCounter.labels("out").inc();
|
||||
if (typeof args[0] === "string" && !socket.clusterio_ignore_dump) {
|
||||
this.controller.debugEvents.emit("message", { direction: "out", content: args[0] });
|
||||
}
|
||||
// @ts-ignore TODO::: Issue with originalSend having multiple signatures ?
|
||||
return originalSend.call(socket, ...args);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import util from "util";
|
||||
|
||||
const endpointHitCounter = new lib.Counter(
|
||||
export const endpointHitCounter = new lib.Counter(
|
||||
"clusterio_controller_http_endpoint_hits_total",
|
||||
"How many requests a particular HTTP endpoint has gotten",
|
||||
{ labels: ["route"], register: false }
|
||||
@@ -11,5 +11,3 @@ endpointHitCounter.labels = util.deprecate(
|
||||
endpointHitCounter.labels,
|
||||
"incrementing endpointHitCounter is no longer needed and has no effect"
|
||||
);
|
||||
|
||||
export default endpointHitCounter;
|
||||
@@ -61,7 +61,7 @@ async function getMetrics(req: Request, res: Response, next: any) {
|
||||
));
|
||||
}
|
||||
|
||||
for await (let result of await lib.defaultRegistry.collect()) {
|
||||
for await (let result of lib.defaultRegistry.collect()) {
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user