listpage-next-nest 0.0.9 → 0.0.22

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.
@@ -34,6 +34,7 @@ __webpack_require__.d(__webpack_exports__, {
34
34
  RequestIdMiddleware: ()=>RequestIdMiddleware,
35
35
  LoggingInterceptor: ()=>LoggingInterceptor,
36
36
  ResponseInterceptor: ()=>ResponseInterceptor,
37
+ StaticRouteModule: ()=>StaticRouteModule,
37
38
  CorsInterceptor: ()=>CorsInterceptor,
38
39
  ApiResponse: ()=>ApiResponse
39
40
  });
@@ -370,6 +371,98 @@ function setup(app) {
370
371
  app.useGlobalFilters(new HttpExceptionFilter());
371
372
  console.log('✅ 全局异常过滤器配置完成');
372
373
  }
374
+ const external_path_namespaceObject = require("path");
375
+ const STATIC_ROUTE_OPTIONS = 'STATIC_ROUTE_OPTIONS';
376
+ const external_fs_namespaceObject = require("fs");
377
+ function static_route_middleware_ts_decorate(decorators, target, key, desc) {
378
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
379
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
380
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
381
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
382
+ }
383
+ function static_route_middleware_ts_metadata(k, v) {
384
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
385
+ }
386
+ function _ts_param(paramIndex, decorator) {
387
+ return function(target, key) {
388
+ decorator(target, key, paramIndex);
389
+ };
390
+ }
391
+ class StaticRouteMiddleware {
392
+ constructor(options){
393
+ this.options = options;
394
+ }
395
+ use(req, res, next) {
396
+ const { rootDir, routeMappings } = this.options;
397
+ if (external_path_namespaceObject.extname(req.path)) {
398
+ const filePath = external_path_namespaceObject.join(this.options.rootDir, req.path);
399
+ if (!(0, external_fs_namespaceObject.existsSync)(filePath)) next(new common_namespaceObject.NotFoundException(`File not found: ${req.path}`));
400
+ res.sendFile(filePath, (err)=>{
401
+ if (err) next(err);
402
+ });
403
+ return;
404
+ }
405
+ for (const mapping of routeMappings)if (req.path.startsWith(mapping.prefix)) {
406
+ const fullPath = external_path_namespaceObject.join(rootDir, mapping.htmlPath);
407
+ return res.sendFile(fullPath, (err)=>{
408
+ if (err) next(err);
409
+ });
410
+ }
411
+ return next();
412
+ }
413
+ }
414
+ StaticRouteMiddleware = static_route_middleware_ts_decorate([
415
+ (0, common_namespaceObject.Injectable)(),
416
+ _ts_param(0, (0, common_namespaceObject.Inject)(STATIC_ROUTE_OPTIONS)),
417
+ static_route_middleware_ts_metadata("design:type", Function),
418
+ static_route_middleware_ts_metadata("design:paramtypes", [
419
+ "undefined" == typeof StaticRouteOptions ? Object : StaticRouteOptions
420
+ ])
421
+ ], StaticRouteMiddleware);
422
+ function static_route_module_ts_decorate(decorators, target, key, desc) {
423
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
424
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
425
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
426
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
427
+ }
428
+ class StaticRouteModule {
429
+ static forRoot(options) {
430
+ return {
431
+ module: StaticRouteModule,
432
+ providers: [
433
+ {
434
+ provide: STATIC_ROUTE_OPTIONS,
435
+ useValue: options
436
+ },
437
+ StaticRouteMiddleware
438
+ ],
439
+ exports: [
440
+ StaticRouteMiddleware
441
+ ]
442
+ };
443
+ }
444
+ static forRootAsync(options) {
445
+ return {
446
+ module: StaticRouteModule,
447
+ imports: options.imports || [],
448
+ providers: [
449
+ {
450
+ provide: STATIC_ROUTE_OPTIONS,
451
+ useFactory: options.useFactory,
452
+ inject: options.inject || []
453
+ },
454
+ StaticRouteMiddleware
455
+ ],
456
+ exports: [
457
+ StaticRouteMiddleware
458
+ ]
459
+ };
460
+ }
461
+ }
462
+ StaticRouteModule = static_route_module_ts_decorate([
463
+ (0, common_namespaceObject.Global)(),
464
+ (0, common_namespaceObject.Module)({})
465
+ ], StaticRouteModule);
373
466
  exports.ApiResponse = __webpack_exports__.ApiResponse;
374
467
  exports.BaseQueryDto = __webpack_exports__.BaseQueryDto;
375
468
  exports.CorsInterceptor = __webpack_exports__.CorsInterceptor;
@@ -381,6 +474,7 @@ exports.RequestContextMiddleware = __webpack_exports__.RequestContextMiddleware;
381
474
  exports.RequestContextService = __webpack_exports__.RequestContextService;
382
475
  exports.RequestIdMiddleware = __webpack_exports__.RequestIdMiddleware;
383
476
  exports.ResponseInterceptor = __webpack_exports__.ResponseInterceptor;
477
+ exports.StaticRouteModule = __webpack_exports__.StaticRouteModule;
384
478
  exports.setup = __webpack_exports__.setup;
385
479
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
386
480
  "ApiResponse",
@@ -394,6 +488,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
394
488
  "RequestContextService",
395
489
  "RequestIdMiddleware",
396
490
  "ResponseInterceptor",
491
+ "StaticRouteModule",
397
492
  "setup"
398
493
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
399
494
  Object.defineProperty(exports, '__esModule', {
@@ -1,5 +1,6 @@
1
1
  import { ArgumentsHost } from '@nestjs/common';
2
2
  import { CallHandler } from '@nestjs/common';
3
+ import { DynamicModule } from '@nestjs/common';
3
4
  import { ExceptionFilter } from '@nestjs/common';
4
5
  import { ExecutionContext } from '@nestjs/common';
5
6
  import { INestApplication } from '@nestjs/common';
@@ -103,6 +104,21 @@ export declare class ResponseInterceptor<T> implements NestInterceptor<T, any> {
103
104
  intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
104
105
  }
105
106
 
107
+ declare interface RouteMapping {
108
+ prefix: string;
109
+ htmlPath: string;
110
+ }
111
+
106
112
  export declare function setup(app: INestApplication): void;
107
113
 
114
+ export declare class StaticRouteModule {
115
+ static forRoot(options: StaticRouteOptions): DynamicModule;
116
+ static forRootAsync(options: any): DynamicModule;
117
+ }
118
+
119
+ export declare interface StaticRouteOptions {
120
+ rootDir: string;
121
+ routeMappings: RouteMapping[];
122
+ }
123
+
108
124
  export { }
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "listpage-next-nest",
3
- "version": "0.0.9",
3
+ "version": "0.0.22",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
- "main": "./dist/cjs/index.js",
7
- "module": "./dist/cjs/index.js",
6
+ "main": "./dist/cjs/index.cjs",
7
+ "module": "./dist/esm/index.js",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/cjs/index.d.ts",
11
- "import": "./dist/cjs/index.js"
11
+ "require": "./dist/cjs/index.cjs",
12
+ "import": "./dist/esm/index.js"
12
13
  }
13
14
  },
14
15
  "types": "./dist/cjs/index.d.ts",