mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-03-11 17:45:30 +00:00
Fix some linting issues
This commit is contained in:
parent
e27e5ff1b2
commit
2908e4f259
8 changed files with 37 additions and 38 deletions
4
@types/ws.d.ts
vendored
4
@types/ws.d.ts
vendored
|
|
@ -1,5 +1,5 @@
|
|||
import { GUIConfig } from "../modules/module.cfg-loader"
|
||||
import { AuthResponse, CheckTokenResponse, EpisodeListResponse, FolderTypes, QueueItem, ResolveItemsData, ResponseBase, SearchData, SearchResponse } from "./messageHandler"
|
||||
import { GUIConfig } from '../modules/module.cfg-loader';
|
||||
import { AuthResponse, CheckTokenResponse, EpisodeListResponse, FolderTypes, QueueItem, ResolveItemsData, ResponseBase, SearchData, SearchResponse } from './messageHandler';
|
||||
|
||||
export type WSMessage<T extends keyof MessageTypes, P extends 0|1 = 0> = {
|
||||
name: T,
|
||||
|
|
|
|||
2
gui.ts
2
gui.ts
|
|
@ -1 +1 @@
|
|||
import './gui/server/index'
|
||||
import './gui/server/index';
|
||||
|
|
@ -18,7 +18,7 @@ export { app, cfg };
|
|||
|
||||
app.use(express.json());
|
||||
app.use(cors());
|
||||
app.use(express.static(path.join(workingDir, 'gui', 'server', 'build'), { maxAge: 1000 * 60 * 20 }))
|
||||
app.use(express.static(path.join(workingDir, 'gui', 'server', 'build'), { maxAge: 1000 * 60 * 20 }));
|
||||
|
||||
const server = app.listen(cfg.gui.port, () => {
|
||||
console.log(`[INFO] GUI server started on port ${cfg.gui.port}`);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export default class ServiceHandler {
|
|||
return respond(false);
|
||||
this.service = undefined;
|
||||
respond(true);
|
||||
})
|
||||
});
|
||||
|
||||
this.ws.events.on('auth', async ({ data }, respond) => {
|
||||
if (this.service === undefined)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { DownloadInfo, FolderTypes, ProgressData, QueueItem } from '../../../@types/messageHandler';
|
||||
import { RandomEvent, RandomEvents } from '../../../@types/randomEvents';
|
||||
import WebSocketHandler from '../websocket';
|
||||
import copy from "copy-to-clipboard";
|
||||
import copy from 'copy-to-clipboard';
|
||||
import open from 'open';
|
||||
import { cfg } from '..';
|
||||
import path from 'path';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { IncomingMessage, Server } from "http";
|
||||
import { IncomingMessage, Server } from 'http';
|
||||
import ws, { WebSocket } from 'ws';
|
||||
import { RandomEvent, RandomEvents } from "../../@types/randomEvents";
|
||||
import { MessageTypes, UnknownWSMessage, WSMessage } from "../../@types/ws";
|
||||
import { EventEmitter } from "events";
|
||||
import { cfg } from ".";
|
||||
import { isSetuped } from "../../modules/module.cfg-loader";
|
||||
import { RandomEvent, RandomEvents } from '../../@types/randomEvents';
|
||||
import { MessageTypes, UnknownWSMessage, WSMessage } from '../../@types/ws';
|
||||
import { EventEmitter } from 'events';
|
||||
import { cfg } from '.';
|
||||
import { isSetuped } from '../../modules/module.cfg-loader';
|
||||
|
||||
declare interface ExternalEvent {
|
||||
on<T extends keyof MessageTypes>(event: T, listener: (msg: WSMessage<T>, respond: (data: MessageTypes[T][1]) => void) => void): this;
|
||||
|
|
@ -37,9 +37,9 @@ export default class WebSocketHandler {
|
|||
name: json.name
|
||||
}), (er) => {
|
||||
if (er)
|
||||
console.log(`[ERROR] [WS] ${er}`)
|
||||
console.log(`[ERROR] [WS] ${er}`);
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -50,7 +50,7 @@ export default class WebSocketHandler {
|
|||
if (!this.authenticate(request)) {
|
||||
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
|
||||
socket.destroy();
|
||||
console.log(`[INFO] [WS] ${request.socket.remoteAddress} tried to connect but used a wrong password.`)
|
||||
console.log(`[INFO] [WS] ${request.socket.remoteAddress} tried to connect but used a wrong password.`);
|
||||
return;
|
||||
}
|
||||
this.wsServer.handleUpgrade(request, socket, head, socket => {
|
||||
|
|
@ -67,7 +67,7 @@ export default class WebSocketHandler {
|
|||
if (er)
|
||||
console.log(`[ERROR] [WS] ${er}`);
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private authenticate(request: IncomingMessage): boolean {
|
||||
|
|
@ -87,7 +87,7 @@ export class PublicWebSocket {
|
|||
console.log(`[INFO] [WS] Connection to public ws from '${req.socket.remoteAddress}'`);
|
||||
socket.on('error', (er) => console.log(`[ERROR] [WS] ${er}`));
|
||||
socket.on('message', (msg) => {
|
||||
const data = JSON.parse(msg.toString()) as UnknownWSMessage
|
||||
const data = JSON.parse(msg.toString()) as UnknownWSMessage;
|
||||
switch (data.name) {
|
||||
case 'setuped':
|
||||
this.send(socket, data.id, data.name, isSetuped());
|
||||
|
|
@ -115,7 +115,7 @@ export class PublicWebSocket {
|
|||
name
|
||||
}), (er) => {
|
||||
if (er)
|
||||
console.log(`[ERROR] [WS] ${er}`)
|
||||
console.log(`[ERROR] [WS] ${er}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -61,8 +61,8 @@ async function buildBinary(buildType: BuildTypes, gui: boolean) {
|
|||
fs.copySync('./docs/', `${buildDir}/docs/`);
|
||||
fs.copySync('./LICENSE.md', `${buildDir}/docs/LICENSE.md`);
|
||||
if (gui) {
|
||||
fs.copySync('./gui', `${buildDir}/gui`)
|
||||
fs.copySync('./node_modules/open/xdg-open', `${buildDir}/xdg-open`)
|
||||
fs.copySync('./gui', `${buildDir}/gui`);
|
||||
fs.copySync('./node_modules/open/xdg-open', `${buildDir}/xdg-open`);
|
||||
}
|
||||
if(fs.existsSync(`${buildsDir}/${buildFull}.7z`)){
|
||||
fs.removeSync(`${buildsDir}/${buildFull}.7z`);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export { workingDir };
|
|||
|
||||
const binCfgFile = path.join(workingDir, 'config', 'bin-path');
|
||||
const dirCfgFile = path.join(workingDir, 'config', 'dir-path');
|
||||
const guiCfgFile = path.join(workingDir, 'config', 'gui')
|
||||
const guiCfgFile = path.join(workingDir, 'config', 'gui');
|
||||
const cliCfgFile = path.join(workingDir, 'config', 'cli-defaults');
|
||||
const sessCfgFile = path.join(workingDir, 'config', 'session');
|
||||
const setupFile = path.join(workingDir, 'config', 'setup');
|
||||
|
|
@ -57,7 +57,7 @@ const writeYamlCfgFile = <T extends keyof WriteObjects>(file: T, data: WriteObje
|
|||
if (fs.existsSync(fn))
|
||||
fs.removeSync(fn);
|
||||
fs.writeFileSync(fn, yaml.stringify(data));
|
||||
}
|
||||
};
|
||||
|
||||
export type GUIConfig = {
|
||||
port: number,
|
||||
|
|
@ -237,21 +237,20 @@ const isSetuped = (): boolean => {
|
|||
if (!fs.existsSync(fn))
|
||||
return false;
|
||||
return JSON.parse(fs.readFileSync(fn).toString()).setuped;
|
||||
}
|
||||
};
|
||||
|
||||
const setSetuped = (bool: boolean) => {
|
||||
const fn = `${setupFile}.json`;
|
||||
if (bool) {
|
||||
fs.writeFileSync(fn, JSON.stringify({
|
||||
setuped: true
|
||||
}, null, 2))
|
||||
}, null, 2));
|
||||
} else {
|
||||
if (fs.existsSync(fn)) {
|
||||
fs.removeSync(fn);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export {
|
||||
|
|
|
|||
Loading…
Reference in a new issue