@luisrodrigues/nestjs-scheduler-dashboard 0.0.5 → 0.0.6

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.
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.startStandaloneServer = startStandaloneServer;
10
10
  const core_1 = require("@nestjs/core");
11
11
  const common_1 = require("@nestjs/common");
12
- const serve_static_1 = require("@nestjs/serve-static");
13
12
  const path_1 = require("path");
14
13
  const fs_1 = require("fs");
15
14
  const jobs_service_1 = require("./jobs.service");
@@ -22,31 +21,38 @@ async function startStandaloneServer(port, jobsService, auth, logger) {
22
21
  };
23
22
  DashboardHttpApp = __decorate([
24
23
  (0, common_1.Module)({
25
- imports: [
26
- serve_static_1.ServeStaticModule.forRoot({
27
- rootPath: UI_PATH,
28
- serveStaticOptions: {
29
- redirect: false,
30
- },
31
- }),
32
- ],
33
24
  controllers: [dashboard_controller_1.DashboardController],
34
25
  providers: [{ provide: jobs_service_1.JobsService, useValue: jobsService }],
35
26
  })
36
27
  ], DashboardHttpApp);
37
- const app = await core_1.NestFactory.create(DashboardHttpApp, { logger: false });
28
+ const nestApp = await core_1.NestFactory.create(DashboardHttpApp, { logger: false });
29
+ const app = nestApp.getHttpAdapter().getInstance();
38
30
  const guard = (0, auth_1.createAuthGuard)(auth);
39
31
  app.use((req, res, next) => {
40
32
  if (req.path.startsWith('/api'))
41
33
  return next();
42
- if (req.path.includes('.'))
43
- return next();
34
+ const filePath = (0, path_1.join)(UI_PATH, req.path);
35
+ if (req.path.includes('.') && (0, fs_1.existsSync)(filePath)) {
36
+ const ext = req.path.split('.').pop()?.toLowerCase();
37
+ const mimeTypes = {
38
+ js: 'application/javascript',
39
+ css: 'text/css',
40
+ html: 'text/html',
41
+ json: 'application/json',
42
+ png: 'image/png',
43
+ svg: 'image/svg+xml',
44
+ ico: 'image/x-icon',
45
+ };
46
+ res.setHeader('Content-Type', mimeTypes[ext ?? ''] ?? 'application/octet-stream');
47
+ (0, fs_1.createReadStream)(filePath).pipe(res);
48
+ return;
49
+ }
44
50
  guard(req, res, () => {
45
51
  res.setHeader('Content-Type', 'text/html; charset=utf-8');
46
52
  res.send(indexHtml);
47
53
  });
48
54
  });
49
- await app.listen(port);
55
+ await nestApp.listen(port);
50
56
  logger.log(`Dashboard running at http://localhost:${port}`);
51
- return app;
57
+ return nestApp;
52
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luisrodrigues/nestjs-scheduler-dashboard",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Dashboard for @nestjs/schedule — embedded UI, job history, metrics, stop/trigger controls",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,13 +22,11 @@
22
22
  "@nestjs/common": "^10.4.15",
23
23
  "@nestjs/core": "^10.4.15",
24
24
  "@nestjs/schedule": "^4.1.2",
25
- "@types/express": "^5.0.0",
26
25
  "@types/node": "^25.5.2",
27
26
  "typescript": "^5.8.3"
28
27
  },
29
28
  "dependencies": {
30
29
  "@nestjs/platform-express": "^10.0.0",
31
- "@nestjs/serve-static": "^4.0.0",
32
30
  "zod": "^4.3.6"
33
31
  },
34
32
  "keywords": [