@xenon-device-management/xenon 1.1.14 → 1.1.16
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/lib/package.json +1 -1
- package/lib/src/app/index.js +33 -2
- package/package.json +1 -1
package/lib/package.json
CHANGED
package/lib/src/app/index.js
CHANGED
|
@@ -49,6 +49,7 @@ exports.createRouter = createRouter;
|
|
|
49
49
|
const express_1 = __importDefault(require("express"));
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
51
|
const fs_1 = __importDefault(require("fs"));
|
|
52
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
52
53
|
const pluginArgs_1 = require("../data-service/pluginArgs");
|
|
53
54
|
const cors_1 = __importDefault(require("cors"));
|
|
54
55
|
const async_lock_1 = __importDefault(require("async-lock"));
|
|
@@ -131,7 +132,28 @@ apiRouter.get('/metrics', (req, res) => __awaiter(void 0, void 0, void 0, functi
|
|
|
131
132
|
res.set('Content-Type', 'text/plain');
|
|
132
133
|
res.send(metrics);
|
|
133
134
|
}));
|
|
134
|
-
const
|
|
135
|
+
const findPublicPath = () => {
|
|
136
|
+
const rootDir = path_1.default.resolve(__dirname, '..', '..');
|
|
137
|
+
const searchPaths = [
|
|
138
|
+
path_1.default.join(rootDir, 'public'), // Production (lib/public)
|
|
139
|
+
path_1.default.join(rootDir, 'src', 'public'), // Development (src/public)
|
|
140
|
+
path_1.default.resolve(__dirname, '../public'), // Alternative structure
|
|
141
|
+
path_1.default.resolve(__dirname, '../../public'),
|
|
142
|
+
path_1.default.resolve(__dirname, '../../../public'),
|
|
143
|
+
];
|
|
144
|
+
for (const p of searchPaths) {
|
|
145
|
+
if (fs_1.default.existsSync(path_1.default.join(p, 'index.html'))) {
|
|
146
|
+
logger_1.default.info(`[Xenon] Dashboard assets found at: ${p}`);
|
|
147
|
+
return p;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Last resort fallback
|
|
151
|
+
const fallback = path_1.default.resolve(__dirname, '../../public');
|
|
152
|
+
logger_1.default.warn(`[Xenon] Could not find dashboard index.html in standard paths. Falling back to: ${fallback}`);
|
|
153
|
+
return fallback;
|
|
154
|
+
};
|
|
155
|
+
const publicPath = findPublicPath();
|
|
156
|
+
logger_1.default.info(`[Xenon] Public assets path resolved to: ${publicPath}`);
|
|
135
157
|
staticFilesRouter.use(express_1.default.static(publicPath));
|
|
136
158
|
router.use('/api', apiRouter);
|
|
137
159
|
router.use('/assets', express_1.default.static(config_1.config.sessionAssetsPath));
|
|
@@ -144,6 +166,8 @@ function createRouter(pluginArgs) {
|
|
|
144
166
|
webhook_1.default.register(apiRouter);
|
|
145
167
|
config_2.default.register(apiRouter, pluginArgs);
|
|
146
168
|
apiRouter.use('/reservation', reservation_1.default);
|
|
169
|
+
// Principal Health: Add ping endpoint
|
|
170
|
+
apiRouter.get('/ping', (req, res) => res.json({ pong: true, version: package_json_1.default.version }));
|
|
147
171
|
// Setup Swagger API documentation at /xenon/api-docs
|
|
148
172
|
try {
|
|
149
173
|
(0, swagger_1.setupSwagger)(router, '/xenon');
|
|
@@ -161,7 +185,14 @@ function createRouter(pluginArgs) {
|
|
|
161
185
|
// Fallback route for client-side routing - serve index.html for all non-API routes
|
|
162
186
|
// MUST be registered after Swagger to avoid interception
|
|
163
187
|
router.get(/^(?!\/api).*/, (req, res) => {
|
|
164
|
-
|
|
188
|
+
const indexPath = path_1.default.join(publicPath, 'index.html');
|
|
189
|
+
if (fs_1.default.existsSync(indexPath)) {
|
|
190
|
+
res.sendFile(indexPath);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
logger_1.default.error(`[Xenon] UI Fallback failed: index.html not found at ${indexPath}`);
|
|
194
|
+
res.status(404).send('Xenon UI assets not found. Check installation.');
|
|
195
|
+
}
|
|
165
196
|
});
|
|
166
197
|
return router;
|
|
167
198
|
}
|
package/package.json
CHANGED