nodestatus-server 1.2.0-beta → 1.2.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.js +59 -19
- package/build/dist/hotaru-admin/assets/LayoutHandler.b94f47a4.js +61 -0
- package/build/dist/hotaru-admin/assets/{Login.9436af39.js → Login.2f40aa4a.js} +1 -1
- package/build/dist/hotaru-admin/assets/{UserOutlined.7b9f806f.js → UserOutlined.cd1982fa.js} +1 -1
- package/build/dist/hotaru-admin/assets/{index.011b6d09.js → index.e95ae70d.js} +1 -1
- package/build/dist/hotaru-admin/assets/{vendor.6aba3586.js → vendor.7188e8d8.js} +1 -1
- package/build/dist/hotaru-admin/index.html +2 -2
- package/build/dist/hotaru-theme/assets/{index.3da88005.js → index.90dd675e.js} +1 -1
- package/build/dist/hotaru-theme/index.html +1 -1
- package/package.json +6 -5
- package/prisma/schema.prisma +10 -0
- package/scripts/init.js +83 -0
- package/build/dist/hotaru-admin/assets/LayoutHandler.ab803b10.js +0 -61
- package/scripts/postinstall.js +0 -33
- package/scripts/prestart.js +0 -16
- package/scripts/utils.js +0 -13
package/build/app.js
CHANGED
|
@@ -53260,11 +53260,15 @@ exports.Option = Option;
|
|
|
53260
53260
|
}(commander, commander.exports));
|
|
53261
53261
|
|
|
53262
53262
|
dotenv__default["default"].config({ path: require$$1$1.resolve(require$$1$3.homedir(), ".nodestatus/.env.local") });
|
|
53263
|
-
commander.exports.program.option("-db, --database <db>", "the path of database", require$$1$3.platform() === "win32" ? require$$1$1.resolve(require$$1$3.homedir(), ".nodestatus/db.sqlite") : "
|
|
53263
|
+
commander.exports.program.option("-db, --database <db>", "the path of database", require$$1$3.platform() === "win32" ? `file:${require$$1$1.resolve(require$$1$3.homedir(), ".nodestatus/db.sqlite")}` : "file:/usr/local/NodeStatus/server/db.sqlite").option("-p, --port <port>", "the port of NodeStatus", "35601").option("-i, --interval <interval>", "update interval", "1500").parse(process.argv);
|
|
53264
53264
|
const options = commander.exports.program.opts();
|
|
53265
|
+
let database = process.env.DATABASE || (process.env.NODE_ENV === "TEST" ? require$$1$1.resolve(__dirname, "../../db.base.sqlite") : options.database);
|
|
53266
|
+
if (!(database.includes("file:") || database.includes("mysql:") || database.includes("postgresql:"))) {
|
|
53267
|
+
database = `file:${database}`;
|
|
53268
|
+
}
|
|
53265
53269
|
const config = {
|
|
53266
53270
|
NODE_ENV: process.env.NODE_ENV,
|
|
53267
|
-
database
|
|
53271
|
+
database,
|
|
53268
53272
|
port: Number(process.env.PORT || options.port),
|
|
53269
53273
|
interval: Number(process.env.INTERVAL || options.interval),
|
|
53270
53274
|
verbose: process.env.VERBOSE === "true",
|
|
@@ -54750,11 +54754,11 @@ var bcryptjs = bcrypt.exports;
|
|
|
54750
54754
|
const prisma = new client.PrismaClient({
|
|
54751
54755
|
datasources: {
|
|
54752
54756
|
db: {
|
|
54753
|
-
url:
|
|
54757
|
+
url: `${config.database}`
|
|
54754
54758
|
}
|
|
54755
54759
|
}
|
|
54756
54760
|
});
|
|
54757
|
-
const actions = new Set(["create", "createMany", "update", "updateMany", "upsert"]);
|
|
54761
|
+
const actions = /* @__PURE__ */ new Set(["create", "createMany", "update", "updateMany", "upsert"]);
|
|
54758
54762
|
const parseFields = async (server) => {
|
|
54759
54763
|
for (const key in server) {
|
|
54760
54764
|
if (server[key] === "") {
|
|
@@ -54778,7 +54782,7 @@ prisma.$use(async (params, next) => {
|
|
|
54778
54782
|
});
|
|
54779
54783
|
|
|
54780
54784
|
let isInitial = true;
|
|
54781
|
-
const orderMap = new Map();
|
|
54785
|
+
const orderMap = /* @__PURE__ */ new Map();
|
|
54782
54786
|
const resolveResult = (item) => {
|
|
54783
54787
|
if (!item)
|
|
54784
54788
|
return item;
|
|
@@ -54876,6 +54880,24 @@ async function setServer$2(username, obj) {
|
|
|
54876
54880
|
obj.username && emitter.emit("update", obj.username, true);
|
|
54877
54881
|
}
|
|
54878
54882
|
|
|
54883
|
+
const createEvent = (username) => prisma.event.create({
|
|
54884
|
+
data: {
|
|
54885
|
+
username
|
|
54886
|
+
}
|
|
54887
|
+
});
|
|
54888
|
+
const updateEvent = (username, resolved = true) => prisma.event.updateMany({
|
|
54889
|
+
where: {
|
|
54890
|
+
AND: [
|
|
54891
|
+
{ username },
|
|
54892
|
+
{ resolved: false }
|
|
54893
|
+
]
|
|
54894
|
+
},
|
|
54895
|
+
data: {
|
|
54896
|
+
resolved
|
|
54897
|
+
}
|
|
54898
|
+
});
|
|
54899
|
+
const readEvents = () => prisma.event.findMany({});
|
|
54900
|
+
|
|
54879
54901
|
async function handleRequest$1(ctx, handler) {
|
|
54880
54902
|
try {
|
|
54881
54903
|
ctx.body = createRes({ data: await handler });
|
|
@@ -54928,13 +54950,16 @@ const delServer$1 = async (ctx) => {
|
|
|
54928
54950
|
await handleRequest$1(ctx, delServer$2(username));
|
|
54929
54951
|
};
|
|
54930
54952
|
const modifyOrder = async (ctx) => {
|
|
54931
|
-
const { order =
|
|
54932
|
-
if (!order) {
|
|
54953
|
+
const { order = [] } = ctx.request.body;
|
|
54954
|
+
if (!order.length) {
|
|
54933
54955
|
ctx.status = 400;
|
|
54934
54956
|
ctx.body = createRes(1, "Wrong request");
|
|
54935
54957
|
return;
|
|
54936
54958
|
}
|
|
54937
|
-
await handleRequest$1(ctx, setOrder(order));
|
|
54959
|
+
await handleRequest$1(ctx, setOrder(order.join(",")));
|
|
54960
|
+
};
|
|
54961
|
+
const queryEvents = async (ctx) => {
|
|
54962
|
+
await handleRequest$1(ctx, readEvents());
|
|
54938
54963
|
};
|
|
54939
54964
|
|
|
54940
54965
|
const router = new router$1({ prefix: "/api" });
|
|
@@ -54945,6 +54970,7 @@ router.post("/server", addServer$1);
|
|
|
54945
54970
|
router.put("/server", setServer$1);
|
|
54946
54971
|
router.put("/server/order", modifyOrder);
|
|
54947
54972
|
router.delete("/server/:username", delServer$1);
|
|
54973
|
+
router.get("/event", queryEvents);
|
|
54948
54974
|
|
|
54949
54975
|
var bufferUtil$1 = {exports: {}};
|
|
54950
54976
|
|
|
@@ -61327,6 +61353,12 @@ async function getServer(username) {
|
|
|
61327
61353
|
function getRawListServers() {
|
|
61328
61354
|
return handleRequest(getListServers$1());
|
|
61329
61355
|
}
|
|
61356
|
+
function createNewEvent(username) {
|
|
61357
|
+
return handleRequest(createEvent(username));
|
|
61358
|
+
}
|
|
61359
|
+
function resolveEvent(username) {
|
|
61360
|
+
return handleRequest(updateEvent(username, true));
|
|
61361
|
+
}
|
|
61330
61362
|
|
|
61331
61363
|
function callHook(instance, hook, ...args) {
|
|
61332
61364
|
try {
|
|
@@ -61338,14 +61370,20 @@ function callHook(instance, hook, ...args) {
|
|
|
61338
61370
|
}
|
|
61339
61371
|
}
|
|
61340
61372
|
class NodeStatus {
|
|
61373
|
+
options;
|
|
61374
|
+
server;
|
|
61375
|
+
ioPub = new ws.Server({ noServer: true });
|
|
61376
|
+
ioConn = new ws.Server({ noServer: true });
|
|
61377
|
+
ipMap = new WeakMap();
|
|
61378
|
+
userMap = /* @__PURE__ */ new Map();
|
|
61379
|
+
isBanned = /* @__PURE__ */ new Map();
|
|
61380
|
+
servers = {};
|
|
61381
|
+
serversPub = [];
|
|
61382
|
+
onServerConnect;
|
|
61383
|
+
onServerBanned;
|
|
61384
|
+
onServerConnected;
|
|
61385
|
+
onServerDisconnected;
|
|
61341
61386
|
constructor(server, options) {
|
|
61342
|
-
this.ioPub = new ws.Server({ noServer: true });
|
|
61343
|
-
this.ioConn = new ws.Server({ noServer: true });
|
|
61344
|
-
this.ipMap = new WeakMap();
|
|
61345
|
-
this.userMap = new Map();
|
|
61346
|
-
this.isBanned = new Map();
|
|
61347
|
-
this.servers = {};
|
|
61348
|
-
this.serversPub = [];
|
|
61349
61387
|
this.server = server;
|
|
61350
61388
|
this.options = options;
|
|
61351
61389
|
emitter.on("update", this.updateStatus.bind(this));
|
|
@@ -61417,12 +61455,14 @@ class NodeStatus {
|
|
|
61417
61455
|
}
|
|
61418
61456
|
socket.send(`You are connecting via: ${ipType}`);
|
|
61419
61457
|
logger.info(`${address} has connected to server`);
|
|
61458
|
+
resolveEvent(username).then();
|
|
61420
61459
|
socket.on("message", (buf2) => this.servers[username].status = decode(buf2));
|
|
61421
61460
|
this.userMap.set(username, socket);
|
|
61422
61461
|
callHook(this, "onServerConnected", socket, username);
|
|
61423
61462
|
socket.once("close", () => {
|
|
61424
61463
|
this.userMap.delete(username);
|
|
61425
61464
|
this.servers[username] && (this.servers[username].status = {});
|
|
61465
|
+
createNewEvent(username).then();
|
|
61426
61466
|
logger.warn(`${address} disconnected`);
|
|
61427
61467
|
callHook(this, "onServerDisconnected", socket, username);
|
|
61428
61468
|
});
|
|
@@ -62000,8 +62040,8 @@ var dist = createHttpsProxyAgent;
|
|
|
62000
62040
|
|
|
62001
62041
|
function createPush(options) {
|
|
62002
62042
|
const pushList = [];
|
|
62003
|
-
const timerMap = new Map();
|
|
62004
|
-
const entities = new Set(["_", "*", "[", "]", "(", ")", "~", "`", ">", "#", "+", "-", "=", "|", "{", "}", ".", "!", "\\"]);
|
|
62043
|
+
const timerMap = /* @__PURE__ */ new Map();
|
|
62044
|
+
const entities = /* @__PURE__ */ new Set(["_", "*", "[", "]", "(", ")", "~", "`", ">", "#", "+", "-", "=", "|", "{", "}", ".", "!", "\\"]);
|
|
62005
62045
|
const parseEntities = (msg) => {
|
|
62006
62046
|
let str;
|
|
62007
62047
|
if (typeof msg !== "string")
|
|
@@ -62066,12 +62106,12 @@ ${str}`;
|
|
|
62066
62106
|
const currentChat = ctx.message.chat.id.toString();
|
|
62067
62107
|
if (chatId.has(currentChat)) {
|
|
62068
62108
|
ctx.reply(`\u{1F34A}NodeStatus
|
|
62069
|
-
\u{1F916} Hi, this chat id is *${currentChat}*\\.
|
|
62109
|
+
\u{1F916} Hi, this chat id is *${parseEntities(currentChat)}*\\.
|
|
62070
62110
|
You have access to this service\\. I will alert you when your servers changed\\.
|
|
62071
62111
|
You are currently using NodeStatus: *${parseEntities(process.env.npm_package_version)}*`, { parse_mode: "MarkdownV2" });
|
|
62072
62112
|
} else {
|
|
62073
62113
|
ctx.reply(`\u{1F34A}NodeStatus
|
|
62074
|
-
\u{1F916} Hi, this chat id is *${currentChat}*\\.
|
|
62114
|
+
\u{1F916} Hi, this chat id is *${parseEntities(currentChat)}*\\.
|
|
62075
62115
|
You *do not* have permission to use this service\\.
|
|
62076
62116
|
Please check your settings\\.`, { parse_mode: "MarkdownV2" });
|
|
62077
62117
|
}
|