@colyseus/monitor 0.18.2 → 0.18.3
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/index.cjs +2 -36
- package/build/index.cjs.map +3 -3
- package/build/index.d.ts +1 -1
- package/build/index.mjs +2 -35
- package/build/index.mjs.map +2 -2
- package/build/static/assets/{index-CtJMymAb.js → index-D9MoG02G.js} +2 -2
- package/build/static/assets/{index-CtJMymAb.js.map → index-D9MoG02G.js.map} +1 -1
- package/build/static/index.html +1 -1
- package/package.json +2 -2
- package/src-backend/index.ts +3 -40
package/build/static/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
7
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
8
8
|
<title>Colyseus Stats</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-D9MoG02G.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-C4SPBCkT.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colyseus/monitor",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Web Monitoring Panel for Colyseus",
|
|
6
6
|
"input": "./src/index.ts",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"node-os-utils": "^2.0.0",
|
|
73
73
|
"zod": "^4.1.12",
|
|
74
|
-
"@colyseus/core": "^0.18.
|
|
74
|
+
"@colyseus/core": "^0.18.6"
|
|
75
75
|
},
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"tag": "next"
|
package/src-backend/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
import { createEndpoint, dualModeEndpoints, matchMaker, type Endpoint } from '@colyseus/core';
|
|
@@ -12,7 +11,7 @@ const UNAVAILABLE_ROOM_ERROR = "@colyseus/monitor: room $roomId is not available
|
|
|
12
11
|
const SPA_DIST = path.resolve(import.meta.dirname, '..', 'build', 'static');
|
|
13
12
|
|
|
14
13
|
export interface MonitorOptions {
|
|
15
|
-
/**
|
|
14
|
+
/** Endpoint path prefix — namespaces the routes when spread into `createRouter`, honored at root express mounts. Under a path mount (`app.use("/stats", monitor())`) the mount path takes over. Defaults to `'/monitor'`. */
|
|
16
15
|
prefix?: string;
|
|
17
16
|
/** Better-call middleware applied to every monitor endpoint — use for auth gating. */
|
|
18
17
|
use?: any[];
|
|
@@ -119,45 +118,9 @@ export function monitor(opts: MonitorOptions = {}) {
|
|
|
119
118
|
}),
|
|
120
119
|
};
|
|
121
120
|
|
|
122
|
-
const SPA_DIST_RESOLVED = path.resolve(SPA_DIST);
|
|
123
|
-
|
|
124
|
-
// Express compat — works with either `app.use("/monitor", monitor())` or
|
|
125
|
-
// `app.use("/", monitor())`. Routing decisions use originalUrl (the same
|
|
126
|
-
// string better-call's getRequest uses to build the dispatched Request URL),
|
|
127
|
-
// so the middleware's match check and the actual dispatch always agree.
|
|
128
121
|
return dualModeEndpoints(endpoints, {
|
|
129
122
|
catchAllKey: 'monitor-static',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const dispatchUrl = ((req as any).originalUrl ?? req.url ?? '').split('?')[0]!;
|
|
134
|
-
|
|
135
|
-
// Bare prefix (`/monitor`) → 301 to canonical `/monitor/`.
|
|
136
|
-
if (prefix && dispatchUrl === prefix) {
|
|
137
|
-
res.writeHead(301, { location: `${prefix}/` });
|
|
138
|
-
res.end();
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const route = specificRouter.findRoute('GET', dispatchUrl);
|
|
143
|
-
if (route && route.data?.path === dispatchUrl) {
|
|
144
|
-
return specificHandler(req as any, res as any).catch(next);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Asset request — only delegate if the file exists on disk.
|
|
148
|
-
if (!dispatchUrl.startsWith(prefix)) { return next(); }
|
|
149
|
-
const rel = dispatchUrl.slice(prefix.length).replace(/^\/+/, '');
|
|
150
|
-
if (!rel || rel.includes('..')) { return next(); }
|
|
151
|
-
const filePath = path.resolve(SPA_DIST_RESOLVED, rel);
|
|
152
|
-
if (!filePath.startsWith(SPA_DIST_RESOLVED + path.sep)) { return next(); }
|
|
153
|
-
|
|
154
|
-
fs.stat(filePath).then((stat) => {
|
|
155
|
-
if (stat.isFile()) {
|
|
156
|
-
fullHandler(req as any, res as any).catch(next);
|
|
157
|
-
} else {
|
|
158
|
-
next();
|
|
159
|
-
}
|
|
160
|
-
}).catch(() => next());
|
|
161
|
-
},
|
|
123
|
+
prefix,
|
|
124
|
+
staticDir: SPA_DIST,
|
|
162
125
|
});
|
|
163
126
|
}
|