@abejarano/ts-express-server 1.5.2 → 1.6.0

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.
Files changed (39) hide show
  1. package/README.md +14 -2
  2. package/dist/BootstrapServer.d.ts +13 -6
  3. package/dist/BootstrapServer.js +30 -23
  4. package/dist/BootstrapStandardServer.d.ts +2 -1
  5. package/dist/BootstrapStandardServer.js +6 -4
  6. package/dist/abstract/ServerModule.d.ts +2 -2
  7. package/dist/abstract/ServerService.d.ts +2 -2
  8. package/dist/abstract/ServerTypes.d.ts +55 -0
  9. package/dist/abstract/ServerTypes.js +8 -0
  10. package/dist/abstract/index.d.ts +1 -0
  11. package/dist/abstract/index.js +1 -0
  12. package/dist/adapters/BunAdapter.d.ts +8 -0
  13. package/dist/adapters/BunAdapter.js +418 -0
  14. package/dist/adapters/ExpressAdapter.d.ts +8 -0
  15. package/dist/adapters/ExpressAdapter.js +40 -0
  16. package/dist/adapters/index.d.ts +2 -0
  17. package/dist/adapters/index.js +18 -0
  18. package/dist/createRouter.d.ts +2 -0
  19. package/dist/createRouter.js +12 -0
  20. package/dist/decorators/Use.d.ts +2 -2
  21. package/dist/index.d.ts +3 -0
  22. package/dist/index.js +2 -0
  23. package/dist/modules/ControllersModule.d.ts +2 -2
  24. package/dist/modules/ControllersModule.js +14 -8
  25. package/dist/modules/CorsModule.d.ts +2 -2
  26. package/dist/modules/CorsModule.js +66 -2
  27. package/dist/modules/FileUploadModule.d.ts +4 -4
  28. package/dist/modules/FileUploadModule.js +43 -6
  29. package/dist/modules/RateLimitModule.d.ts +4 -4
  30. package/dist/modules/RateLimitModule.js +48 -7
  31. package/dist/modules/RequestContextModule.d.ts +2 -9
  32. package/dist/modules/RequestContextModule.js +53 -4
  33. package/dist/modules/RoutesModule.d.ts +4 -4
  34. package/dist/modules/RoutesModule.js +12 -3
  35. package/dist/modules/SecurityModule.d.ts +4 -4
  36. package/dist/modules/SecurityModule.js +43 -6
  37. package/dist/testing/createDecoratedTestApp.d.ts +3 -3
  38. package/dist/testing/createDecoratedTestApp.js +8 -4
  39. package/package.json +6 -7
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CorsModule = void 0;
7
7
  const abstract_1 = require("../abstract");
8
+ const abstract_2 = require("../abstract");
8
9
  const cors_1 = __importDefault(require("cors"));
9
10
  class CorsModule extends abstract_1.BaseServerModule {
10
11
  constructor(corsOptions) {
@@ -20,8 +21,71 @@ class CorsModule extends abstract_1.BaseServerModule {
20
21
  getModuleName() {
21
22
  return this.name;
22
23
  }
23
- init(app) {
24
- app.use((0, cors_1.default)(this.corsOptions));
24
+ init(app, context) {
25
+ const runtime = context?.runtime ?? abstract_2.ServerRuntime.Express;
26
+ if (runtime === abstract_2.ServerRuntime.Express) {
27
+ app.use((0, cors_1.default)(this.corsOptions));
28
+ return;
29
+ }
30
+ app.use(createCorsMiddleware(this.corsOptions));
25
31
  }
26
32
  }
27
33
  exports.CorsModule = CorsModule;
34
+ const createCorsMiddleware = (options) => {
35
+ return (req, res, next) => {
36
+ const originHeader = String(req.headers?.origin || "");
37
+ const allowOrigin = resolveOrigin(options.origin, originHeader);
38
+ if (allowOrigin) {
39
+ res.set("access-control-allow-origin", allowOrigin);
40
+ }
41
+ if (options.credentials) {
42
+ res.set("access-control-allow-credentials", "true");
43
+ }
44
+ if (options.methods) {
45
+ res.set("access-control-allow-methods", Array.isArray(options.methods) ? options.methods.join(",") : options.methods);
46
+ }
47
+ if (options.allowedHeaders) {
48
+ res.set("access-control-allow-headers", Array.isArray(options.allowedHeaders)
49
+ ? options.allowedHeaders.join(",")
50
+ : options.allowedHeaders);
51
+ }
52
+ if (options.maxAge !== undefined) {
53
+ res.set("access-control-max-age", String(options.maxAge));
54
+ }
55
+ if (req.method === "OPTIONS") {
56
+ res.status(204).end();
57
+ return;
58
+ }
59
+ next();
60
+ };
61
+ };
62
+ const resolveOrigin = (originOption, requestOrigin) => {
63
+ if (!originOption || originOption === "*") {
64
+ return "*";
65
+ }
66
+ if (originOption === true) {
67
+ return requestOrigin || "*";
68
+ }
69
+ if (typeof originOption === "string") {
70
+ return originOption;
71
+ }
72
+ if (Array.isArray(originOption)) {
73
+ return originOption.includes(requestOrigin) ? requestOrigin : undefined;
74
+ }
75
+ if (typeof originOption === "function") {
76
+ let resolved;
77
+ originOption(requestOrigin, (err, value) => {
78
+ if (err) {
79
+ return;
80
+ }
81
+ if (value === true) {
82
+ resolved = requestOrigin || "*";
83
+ }
84
+ else if (typeof value === "string") {
85
+ resolved = value;
86
+ }
87
+ });
88
+ return resolved;
89
+ }
90
+ return undefined;
91
+ };
@@ -1,11 +1,11 @@
1
- import { Express } from "express";
2
- import fileUpload from "express-fileupload";
3
1
  import { BaseServerModule } from "../abstract";
2
+ import { ServerApp, ServerContext } from "../abstract";
3
+ import type { Options as FileUploadOptions } from "express-fileupload";
4
4
  export declare class FileUploadModule extends BaseServerModule {
5
5
  name: string;
6
6
  priority: number;
7
7
  private fileUploadOptions;
8
- constructor(fileUploadOptions?: fileUpload.Options);
8
+ constructor(fileUploadOptions?: FileUploadOptions);
9
9
  getModuleName(): string;
10
- init(app: Express): void;
10
+ init(app: ServerApp, context?: ServerContext): void;
11
11
  }
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.FileUploadModule = void 0;
7
- const express_fileupload_1 = __importDefault(require("express-fileupload"));
8
4
  const abstract_1 = require("../abstract");
5
+ const abstract_2 = require("../abstract");
9
6
  class FileUploadModule extends abstract_1.BaseServerModule {
10
7
  constructor(fileUploadOptions) {
11
8
  super();
@@ -20,8 +17,48 @@ class FileUploadModule extends abstract_1.BaseServerModule {
20
17
  getModuleName() {
21
18
  return this.name;
22
19
  }
23
- init(app) {
24
- app.use((0, express_fileupload_1.default)(this.fileUploadOptions));
20
+ init(app, context) {
21
+ const runtime = context?.runtime ?? abstract_2.ServerRuntime.Express;
22
+ if (runtime === abstract_2.ServerRuntime.Express) {
23
+ const fileUpload = require("express-fileupload");
24
+ app.use(fileUpload(this.fileUploadOptions));
25
+ return;
26
+ }
27
+ app.use(createBunFileUploadMiddleware());
25
28
  }
26
29
  }
27
30
  exports.FileUploadModule = FileUploadModule;
31
+ const createBunFileUploadMiddleware = () => {
32
+ return async (req, _res, next) => {
33
+ if (!req.raw || req.files) {
34
+ return next();
35
+ }
36
+ const contentType = String(req.headers?.["content-type"] || "");
37
+ if (!contentType.includes("multipart/form-data")) {
38
+ return next();
39
+ }
40
+ try {
41
+ const formData = await req.raw.formData();
42
+ const files = {};
43
+ const body = {};
44
+ formData.forEach((value, key) => {
45
+ if (value instanceof File) {
46
+ files[key] = value;
47
+ }
48
+ else {
49
+ body[key] = value;
50
+ }
51
+ });
52
+ if (Object.keys(files).length) {
53
+ req.files = files;
54
+ }
55
+ if (Object.keys(body).length && req.body === undefined) {
56
+ req.body = body;
57
+ }
58
+ }
59
+ catch {
60
+ // Ignore malformed multipart payloads.
61
+ }
62
+ next();
63
+ };
64
+ };
@@ -1,11 +1,11 @@
1
- import { Express } from "express";
2
1
  import { BaseServerModule } from "../abstract";
3
- import rateLimit from "express-rate-limit";
2
+ import { ServerApp, ServerContext } from "../abstract";
3
+ import type { Options as RateLimitOptions } from "express-rate-limit";
4
4
  export declare class RateLimitModule extends BaseServerModule {
5
5
  name: string;
6
6
  priority: number;
7
7
  private limiterOptions;
8
- constructor(limiterOptions?: Parameters<typeof rateLimit>[0]);
8
+ constructor(limiterOptions?: Partial<RateLimitOptions>);
9
9
  getModuleName(): string;
10
- init(app: Express): void;
10
+ init(app: ServerApp, context?: ServerContext): void;
11
11
  }
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.RateLimitModule = void 0;
7
4
  const abstract_1 = require("../abstract");
8
- const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
5
+ const abstract_2 = require("../abstract");
9
6
  class RateLimitModule extends abstract_1.BaseServerModule {
10
7
  constructor(limiterOptions) {
11
8
  super();
@@ -21,9 +18,53 @@ class RateLimitModule extends abstract_1.BaseServerModule {
21
18
  getModuleName() {
22
19
  return this.name;
23
20
  }
24
- init(app) {
25
- const limiter = (0, express_rate_limit_1.default)(this.limiterOptions);
26
- app.use(limiter);
21
+ init(app, context) {
22
+ const runtime = context?.runtime ?? abstract_2.ServerRuntime.Express;
23
+ if (runtime === abstract_2.ServerRuntime.Express) {
24
+ const rateLimitModule = require("express-rate-limit");
25
+ const rateLimit = rateLimitModule.default ?? rateLimitModule;
26
+ const limiter = rateLimit(this.limiterOptions);
27
+ app.use(limiter);
28
+ return;
29
+ }
30
+ app.use(createRateLimitMiddleware(this.limiterOptions));
27
31
  }
28
32
  }
29
33
  exports.RateLimitModule = RateLimitModule;
34
+ const createRateLimitMiddleware = (options) => {
35
+ const windowMsOption = options?.windowMs;
36
+ const windowMs = typeof windowMsOption === "number" ? windowMsOption : 8 * 60 * 1000;
37
+ const legacyMax = options?.max;
38
+ const limitOption = options?.limit ?? legacyMax;
39
+ const limit = typeof limitOption === "number" ? limitOption : 100;
40
+ const hits = new Map();
41
+ return (req, res, next) => {
42
+ const key = req.ip || String(req.headers?.["x-forwarded-for"] || "unknown");
43
+ const now = Date.now();
44
+ const existing = hits.get(key);
45
+ if (!existing || existing.expiresAt <= now) {
46
+ hits.set(key, { count: 1, expiresAt: now + windowMs });
47
+ }
48
+ else {
49
+ existing.count += 1;
50
+ }
51
+ const current = hits.get(key);
52
+ const remaining = Math.max(0, limit - current.count);
53
+ if (options?.standardHeaders) {
54
+ res.set("ratelimit-limit", String(limit));
55
+ res.set("ratelimit-remaining", String(remaining));
56
+ res.set("ratelimit-reset", String(Math.ceil(current.expiresAt / 1000)));
57
+ }
58
+ if (current.count > limit) {
59
+ const message = typeof options?.message === "string" ||
60
+ (typeof options?.message === "object" && options?.message)
61
+ ? options.message
62
+ : undefined;
63
+ res.status(429).json(message || {
64
+ message: "Too many requests, please try again later.",
65
+ });
66
+ return;
67
+ }
68
+ next();
69
+ };
70
+ };
@@ -1,16 +1,9 @@
1
- import { Express } from "express";
2
1
  import { BaseServerModule } from "../abstract";
3
- declare global {
4
- namespace Express {
5
- interface Request {
6
- requestId?: string;
7
- }
8
- }
9
- }
2
+ import { ServerApp, ServerContext } from "../abstract";
10
3
  export declare class RequestContextModule extends BaseServerModule {
11
4
  name: string;
12
5
  priority: number;
13
- init(app: Express): void;
6
+ init(app: ServerApp, _context?: ServerContext): void;
14
7
  getModuleName(): string;
15
8
  }
16
9
  interface Context {
@@ -1,7 +1,39 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.RequestContext = exports.RequestContextModule = void 0;
4
- const uuid_1 = require("uuid");
5
37
  const abstract_1 = require("../abstract");
6
38
  const async_hooks_1 = require("async_hooks");
7
39
  class RequestContextModule extends abstract_1.BaseServerModule {
@@ -10,12 +42,13 @@ class RequestContextModule extends abstract_1.BaseServerModule {
10
42
  this.name = "RequestContext";
11
43
  this.priority = -50;
12
44
  }
13
- init(app) {
14
- const requestContextMiddleware = (req, res, next) => {
45
+ init(app, _context) {
46
+ const requestContextMiddleware = async (req, _res, next) => {
15
47
  const incomingRequestId = req.headers["x-request-id"];
16
48
  const requestId = (Array.isArray(incomingRequestId)
17
49
  ? incomingRequestId[0]
18
- : incomingRequestId) || (0, uuid_1.v4)();
50
+ : incomingRequestId) || (await createRequestId());
51
+ req.requestId = requestId;
19
52
  RequestContext.run({ requestId }, () => {
20
53
  next();
21
54
  });
@@ -43,3 +76,19 @@ class RequestContext {
43
76
  }
44
77
  exports.RequestContext = RequestContext;
45
78
  RequestContext.storage = new async_hooks_1.AsyncLocalStorage();
79
+ const createRequestId = async () => {
80
+ const cryptoObj = globalThis.crypto;
81
+ if (cryptoObj?.randomUUID) {
82
+ return cryptoObj.randomUUID();
83
+ }
84
+ try {
85
+ const uuidModule = (await Promise.resolve().then(() => __importStar(require("uuid"))));
86
+ if (uuidModule.v4) {
87
+ return uuidModule.v4();
88
+ }
89
+ }
90
+ catch {
91
+ // Ignore and fallback.
92
+ }
93
+ return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
94
+ };
@@ -1,9 +1,9 @@
1
- import { Express, RequestHandler, Router } from "express";
2
1
  import { BaseServerModule } from "../abstract";
2
+ import { ServerApp, ServerContext, ServerHandler, ServerRouter } from "../abstract";
3
3
  export interface RouteConfig {
4
4
  path: string;
5
- router: Router;
6
- middleware?: RequestHandler[] | RequestHandler;
5
+ router: ServerRouter;
6
+ middleware?: ServerHandler[] | ServerHandler;
7
7
  }
8
8
  export declare class RoutesModule extends BaseServerModule {
9
9
  name: string;
@@ -13,5 +13,5 @@ export declare class RoutesModule extends BaseServerModule {
13
13
  getModuleName(): string;
14
14
  addRoute(route: RouteConfig): void;
15
15
  addRoutes(routes: RouteConfig[]): void;
16
- init(app: Express): void;
16
+ init(app: ServerApp, context?: ServerContext): void;
17
17
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RoutesModule = void 0;
4
4
  const abstract_1 = require("../abstract");
5
+ const abstract_2 = require("../abstract");
5
6
  class RoutesModule extends abstract_1.BaseServerModule {
6
7
  constructor(routes = []) {
7
8
  super();
@@ -20,10 +21,18 @@ class RoutesModule extends abstract_1.BaseServerModule {
20
21
  addRoutes(routes) {
21
22
  this.routes.push(...routes);
22
23
  }
23
- init(app) {
24
+ init(app, context) {
25
+ if (context?.runtime === abstract_2.ServerRuntime.Bun) {
26
+ console.warn("[RoutesModule] Express routers are not supported on Bun. Migrate to decorated controllers for Bun runtime.");
27
+ }
24
28
  this.routes.forEach(({ path, router, middleware }) => {
25
- if (middleware && middleware.length > 0) {
26
- app.use(path, middleware, router);
29
+ const middlewareList = Array.isArray(middleware)
30
+ ? middleware
31
+ : middleware
32
+ ? [middleware]
33
+ : [];
34
+ if (middlewareList.length > 0) {
35
+ app.use(path, ...middlewareList, router);
27
36
  }
28
37
  else {
29
38
  app.use(path, router);
@@ -1,11 +1,11 @@
1
- import { Express } from "express";
2
- import helmet from "helmet";
3
1
  import { BaseServerModule } from "../abstract";
2
+ import { ServerApp, ServerContext } from "../abstract";
3
+ import type { HelmetOptions } from "helmet";
4
4
  export declare class SecurityModule extends BaseServerModule {
5
5
  name: string;
6
6
  priority: number;
7
7
  private readonly helmetOptions;
8
- constructor(helmetOptions?: Parameters<typeof helmet>[0]);
8
+ constructor(helmetOptions?: HelmetOptions);
9
9
  getModuleName(): string;
10
- init(app: Express): void;
10
+ init(app: ServerApp, context?: ServerContext): void;
11
11
  }
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.SecurityModule = void 0;
7
- const helmet_1 = __importDefault(require("helmet"));
8
4
  const abstract_1 = require("../abstract");
5
+ const abstract_2 = require("../abstract");
9
6
  class SecurityModule extends abstract_1.BaseServerModule {
10
7
  constructor(helmetOptions) {
11
8
  super();
@@ -29,8 +26,48 @@ class SecurityModule extends abstract_1.BaseServerModule {
29
26
  getModuleName() {
30
27
  return this.name;
31
28
  }
32
- init(app) {
33
- app.use((0, helmet_1.default)(this.helmetOptions));
29
+ init(app, context) {
30
+ const runtime = context?.runtime ?? abstract_2.ServerRuntime.Express;
31
+ if (runtime === abstract_2.ServerRuntime.Express) {
32
+ const helmetModule = require("helmet");
33
+ const helmet = helmetModule.default ?? helmetModule;
34
+ app.use(helmet(this.helmetOptions));
35
+ return;
36
+ }
37
+ app.use(createSecurityMiddleware(this.helmetOptions));
34
38
  }
35
39
  }
36
40
  exports.SecurityModule = SecurityModule;
41
+ const createSecurityMiddleware = (options) => {
42
+ return (_req, res, next) => {
43
+ const frameguard = options?.frameguard;
44
+ if (frameguard && typeof frameguard === "object" && "action" in frameguard) {
45
+ const action = frameguard.action;
46
+ if (action) {
47
+ res.set("x-frame-options", action.toUpperCase());
48
+ }
49
+ }
50
+ if (options?.ieNoOpen !== false) {
51
+ res.set("x-download-options", "noopen");
52
+ }
53
+ if (options?.noSniff !== false) {
54
+ res.set("x-content-type-options", "nosniff");
55
+ }
56
+ if (options?.originAgentCluster) {
57
+ res.set("origin-agent-cluster", "?1");
58
+ }
59
+ if (options?.permittedCrossDomainPolicies === false) {
60
+ res.set("x-permitted-cross-domain-policies", "none");
61
+ }
62
+ const referrerPolicy = options?.referrerPolicy;
63
+ if (referrerPolicy && typeof referrerPolicy === "object" && "policy" in referrerPolicy) {
64
+ res.set("referrer-policy", Array.isArray(referrerPolicy.policy)
65
+ ? referrerPolicy.policy.join(",")
66
+ : referrerPolicy.policy);
67
+ }
68
+ if (options?.dnsPrefetchControl) {
69
+ res.set("x-dns-prefetch-control", "on");
70
+ }
71
+ next();
72
+ };
73
+ };
@@ -1,7 +1,6 @@
1
- import { Express } from "express";
2
1
  import type { BootstrapServer } from "../BootstrapServer";
3
2
  import { ControllersModule } from "../modules";
4
- import { BaseServerService } from "../abstract";
3
+ import { BaseServerService, ServerApp, ServerRuntime } from "../abstract";
5
4
  import { BootstrapStandardServerOptions } from "../BootstrapStandardServer";
6
5
  type ControllerClass<T = any> = new (...args: any[]) => T;
7
6
  export interface DecoratedTestAppOptions {
@@ -10,9 +9,10 @@ export interface DecoratedTestAppOptions {
10
9
  port?: number;
11
10
  services?: BaseServerService[];
12
11
  standardOptions?: BootstrapStandardServerOptions;
12
+ runtime?: ServerRuntime;
13
13
  }
14
14
  export interface DecoratedTestAppResult {
15
- app: Express;
15
+ app: ServerApp;
16
16
  server: BootstrapServer;
17
17
  stop: () => Promise<void>;
18
18
  }
@@ -12,6 +12,7 @@ const mergeOptions = (base, override) => {
12
12
  ...(override.services ?? []),
13
13
  ];
14
14
  return {
15
+ runtime: override.runtime ?? base.runtime,
15
16
  services: mergedServices.length ? mergedServices : undefined,
16
17
  modules: {
17
18
  ...(base.modules ?? {}),
@@ -31,15 +32,18 @@ async function createDecoratedTestApp(options) {
31
32
  },
32
33
  };
33
34
  const mergedOptions = mergeOptions(baseOptions, standardOptions);
34
- const server = (0, BootstrapStandardServer_1.BootstrapStandardServer)(port, moduleInstance, mergedOptions);
35
+ const server = (0, BootstrapStandardServer_1.BootstrapStandardServer)(port, moduleInstance, {
36
+ ...mergedOptions,
37
+ runtime: options.runtime ?? mergedOptions.runtime,
38
+ });
35
39
  await server.initialize();
36
40
  return {
37
41
  app: server.getApp(),
38
42
  server,
39
43
  stop: async () => {
40
- const httpServer = server.getHttpServer();
41
- if (httpServer) {
42
- await new Promise((resolve) => httpServer.close(() => resolve()));
44
+ const serverInstance = server.getServer();
45
+ if (serverInstance) {
46
+ await new Promise((resolve) => serverInstance.close(() => resolve()));
43
47
  }
44
48
  },
45
49
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@abejarano/ts-express-server",
3
3
  "author": "angel bejarano / angel.bejarano@jaspesoft.com",
4
- "version": "1.5.2",
4
+ "version": "1.6.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
@@ -33,9 +33,9 @@
33
33
  "body-parser": "^2.2.1",
34
34
  "cookie-parser": "^1.4.7",
35
35
  "cors": "^2.8.5",
36
- "express": "^5.1.0",
36
+ "express": "^5.2.1",
37
37
  "express-fileupload": "^1.5.2",
38
- "express-rate-limit": "^8.1.0",
38
+ "express-rate-limit": "^8.2.1",
39
39
  "helmet": "^8.1.0",
40
40
  "reflect-metadata": "^0.2.2",
41
41
  "uuid": "^13.0.0"
@@ -46,16 +46,15 @@
46
46
  "@types/body-parser": "^1.19.6",
47
47
  "@types/cookie-parser": "^1.4.9",
48
48
  "@types/cors": "^2.8.19",
49
- "@types/express": "^5.0.3",
49
+ "@types/express": "^5.0.6",
50
50
  "@types/express-fileupload": "^1.5.1",
51
- "@types/express-rate-limit": "^6.0.2",
52
51
  "@types/jest": "^30.0.0",
53
- "@types/node": "^24.6.0",
52
+ "@types/node": "^25.0.3",
54
53
  "@types/supertest": "^6.0.3",
55
54
  "jest": "^30.2.0",
56
55
  "prettier": "^3.6.2",
57
56
  "rimraf": "^6.0.1",
58
- "semantic-release": "^24.2.9",
57
+ "semantic-release": "^25.0.2",
59
58
  "supertest": "^7.1.4",
60
59
  "ts-jest": "^29.4.5",
61
60
  "typescript": "^5.9.3"