Skip to content

Commit

Permalink
fix: config
Browse files Browse the repository at this point in the history
  • Loading branch information
whes1015 committed Dec 2, 2024
1 parent c03a739 commit 9e1f2eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 123 deletions.
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const config = require("./src/utils/config");
const config = require("../config/config");

const path = require("path");

class Plugin {
static instance = null;

#ctx;
#config;
#logger;

constructor(ctx) {
if (Plugin.instance) return Plugin.instance;

this.#ctx = ctx;
this.#config = new config(this.#ctx);
this.#config = null;
this.config = {};
this.logger = null;

Expand All @@ -25,14 +26,18 @@ class Plugin {
}

onLoad() {
const { Logger } = this.#ctx;

this.config = this.#config.getConfig();
const { Logger, info } = this.#ctx;

const { CustomLogger } =
require("./src/utils/logger").createCustomLogger(Logger);
this.logger = new CustomLogger("websocket");

const defaultDir = path.join(info.pluginDir, "./resource/default.yml");
const configDir = path.join(info.pluginDir, "./config.yml");

this.#config = new config(this.logger, defaultDir, configDir);
this.config = this.#config.getConfig();

const server = require("./src/server");
new server(this.config.server);
}
Expand Down
7 changes: 4 additions & 3 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "websocket",
"version": "0.0.9",
"version": "1.0.0",
"description": {
"zh_tw": "TREM-Lite websocket Plugin"
},
"author": ["whes1015"],
"dependencies": {
"trem": ">=3.0.0",
"exptech": ">=1.0.0"
"trem": ">=3.1.0",
"exptech": ">=1.0.0",
"config": ">=1.0.0"
},
"resources": ["AGPL-3.0"],
"link": "https://github.com/ExpTechTW/TREM-Websocket-Plugin"
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const WebSocket = require("ws");

const logger = require("./utils/logger");

const Config = require("./utils/config");
const Config = require("../../config/config");

const config = new Config();

Expand Down
113 changes: 0 additions & 113 deletions src/utils/config.js

This file was deleted.

0 comments on commit 9e1f2eb

Please sign in to comment.