@forklaunch/express 0.5.7 → 0.5.9

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/index.d.mts CHANGED
@@ -3,6 +3,7 @@ import { ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefini
3
3
  import { AnySchemaValidator, LiteralSchema, IdiomaticSchema, SchemaResolve } from '@forklaunch/validator';
4
4
  import { OptionsText, OptionsJson, OptionsUrlencoded } from 'body-parser';
5
5
  import { BusboyConfig } from 'busboy';
6
+ import { CorsOptions } from 'cors';
6
7
  import { Express, RequestHandler, Request, Response, NextFunction, Router as Router$1 } from 'express';
7
8
  import { Server } from 'http';
8
9
  import express from 'express-serve-static-core';
@@ -20,7 +21,7 @@ import { ParsedQs } from 'qs';
20
21
  * ```
21
22
  */
22
23
  declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
23
- private readonly docsConfiguration?;
24
+ private docsConfiguration;
24
25
  /**
25
26
  * Creates an instance of Application.
26
27
  *
@@ -28,11 +29,13 @@ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpre
28
29
  * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
29
30
  * @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
30
31
  */
31
- constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration | undefined, options?: {
32
+ constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: {
33
+ docs?: DocsConfiguration;
32
34
  busboy?: BusboyConfig;
33
35
  text?: OptionsText;
34
36
  json?: OptionsJson;
35
37
  urlencoded?: OptionsUrlencoded;
38
+ cors?: CorsOptions;
36
39
  });
37
40
  /**
38
41
  * Starts the Express server and sets up API documentation (Swagger/Scalar).
@@ -1974,11 +1977,13 @@ declare const unsubscribe: <SV extends AnySchemaValidator, Path extends `/${stri
1974
1977
  * @param {SV} schemaValidator - The schema validator.
1975
1978
  * @returns {Application<SV>} - The new application instance.
1976
1979
  */
1977
- declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration, options?: {
1980
+ declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: {
1981
+ docs?: DocsConfiguration;
1978
1982
  busboy?: BusboyConfig;
1979
1983
  text?: OptionsText;
1980
1984
  json?: OptionsJson;
1981
1985
  urlencoded?: OptionsUrlencoded;
1986
+ cors?: CorsOptions;
1982
1987
  }): Application<SV>;
1983
1988
  /**
1984
1989
  * Creates a new instance of Router with the given base path and schema validator.
package/lib/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefini
3
3
  import { AnySchemaValidator, LiteralSchema, IdiomaticSchema, SchemaResolve } from '@forklaunch/validator';
4
4
  import { OptionsText, OptionsJson, OptionsUrlencoded } from 'body-parser';
5
5
  import { BusboyConfig } from 'busboy';
6
+ import { CorsOptions } from 'cors';
6
7
  import { Express, RequestHandler, Request, Response, NextFunction, Router as Router$1 } from 'express';
7
8
  import { Server } from 'http';
8
9
  import express from 'express-serve-static-core';
@@ -20,7 +21,7 @@ import { ParsedQs } from 'qs';
20
21
  * ```
21
22
  */
22
23
  declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
23
- private readonly docsConfiguration?;
24
+ private docsConfiguration;
24
25
  /**
25
26
  * Creates an instance of Application.
26
27
  *
@@ -28,11 +29,13 @@ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpre
28
29
  * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
29
30
  * @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
30
31
  */
31
- constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration | undefined, options?: {
32
+ constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: {
33
+ docs?: DocsConfiguration;
32
34
  busboy?: BusboyConfig;
33
35
  text?: OptionsText;
34
36
  json?: OptionsJson;
35
37
  urlencoded?: OptionsUrlencoded;
38
+ cors?: CorsOptions;
36
39
  });
37
40
  /**
38
41
  * Starts the Express server and sets up API documentation (Swagger/Scalar).
@@ -1974,11 +1977,13 @@ declare const unsubscribe: <SV extends AnySchemaValidator, Path extends `/${stri
1974
1977
  * @param {SV} schemaValidator - The schema validator.
1975
1978
  * @returns {Application<SV>} - The new application instance.
1976
1979
  */
1977
- declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration, options?: {
1980
+ declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: {
1981
+ docs?: DocsConfiguration;
1978
1982
  busboy?: BusboyConfig;
1979
1983
  text?: OptionsText;
1980
1984
  json?: OptionsJson;
1981
1985
  urlencoded?: OptionsUrlencoded;
1986
+ cors?: CorsOptions;
1982
1987
  }): Application<SV>;
1983
1988
  /**
1984
1989
  * Creates a new instance of Router with the given base path and schema validator.
package/lib/index.js CHANGED
@@ -88,7 +88,15 @@ function contentParse(options2) {
88
88
  chunks.push(chunk);
89
89
  });
90
90
  file.on("end", () => {
91
- const fileBuffer = Buffer.concat(chunks);
91
+ const fileBuffer = new Uint8Array(
92
+ chunks.reduce((acc, chunk) => {
93
+ const arr = new Uint8Array(chunk);
94
+ const tmp = new Uint8Array(acc.length + arr.length);
95
+ tmp.set(acc, 0);
96
+ tmp.set(arr, acc.length);
97
+ return tmp;
98
+ }, new Uint8Array())
99
+ );
92
100
  body[fieldname] = fileBuffer.toString();
93
101
  });
94
102
  });
@@ -152,6 +160,7 @@ function enrichResponseTransmission(req, res, next) {
152
160
 
153
161
  // src/expressApplication.ts
154
162
  var Application = class extends import_http3.ForklaunchExpressLikeApplication {
163
+ docsConfiguration;
155
164
  /**
156
165
  * Creates an instance of Application.
157
166
  *
@@ -159,7 +168,7 @@ var Application = class extends import_http3.ForklaunchExpressLikeApplication {
159
168
  * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
160
169
  * @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
161
170
  */
162
- constructor(schemaValidator, openTelemetryCollector, docsConfiguration, options2) {
171
+ constructor(schemaValidator, openTelemetryCollector, options2) {
163
172
  super(
164
173
  schemaValidator,
165
174
  (0, import_express2.default)(),
@@ -167,9 +176,10 @@ var Application = class extends import_http3.ForklaunchExpressLikeApplication {
167
176
  contentParse(options2),
168
177
  enrichResponseTransmission
169
178
  ],
170
- openTelemetryCollector
179
+ openTelemetryCollector,
180
+ options2
171
181
  );
172
- this.docsConfiguration = docsConfiguration;
182
+ this.docsConfiguration = options2?.docs;
173
183
  }
174
184
  listen(...args) {
175
185
  const port = typeof args[0] === "number" ? args[0] : Number(process.env.PORT);
@@ -592,13 +602,8 @@ var unsubscribe = (schemaValidator, path, contractDetails, ...handlers2) => {
592
602
  };
593
603
 
594
604
  // index.ts
595
- function forklaunchExpress(schemaValidator, openTelemetryCollector, docsConfiguration, options2) {
596
- return new Application(
597
- schemaValidator,
598
- openTelemetryCollector,
599
- docsConfiguration,
600
- options2
601
- );
605
+ function forklaunchExpress(schemaValidator, openTelemetryCollector, options2) {
606
+ return new Application(schemaValidator, openTelemetryCollector, options2);
602
607
  }
603
608
  function forklaunchRouter(basePath, schemaValidator, openTelemetryCollector, options2) {
604
609
  const router = new Router(
package/lib/index.mjs CHANGED
@@ -57,7 +57,15 @@ function contentParse(options2) {
57
57
  chunks.push(chunk);
58
58
  });
59
59
  file.on("end", () => {
60
- const fileBuffer = Buffer.concat(chunks);
60
+ const fileBuffer = new Uint8Array(
61
+ chunks.reduce((acc, chunk) => {
62
+ const arr = new Uint8Array(chunk);
63
+ const tmp = new Uint8Array(acc.length + arr.length);
64
+ tmp.set(acc, 0);
65
+ tmp.set(arr, acc.length);
66
+ return tmp;
67
+ }, new Uint8Array())
68
+ );
61
69
  body[fieldname] = fileBuffer.toString();
62
70
  });
63
71
  });
@@ -123,6 +131,7 @@ function enrichResponseTransmission(req, res, next) {
123
131
 
124
132
  // src/expressApplication.ts
125
133
  var Application = class extends ForklaunchExpressLikeApplication {
134
+ docsConfiguration;
126
135
  /**
127
136
  * Creates an instance of Application.
128
137
  *
@@ -130,7 +139,7 @@ var Application = class extends ForklaunchExpressLikeApplication {
130
139
  * @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
131
140
  * @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
132
141
  */
133
- constructor(schemaValidator, openTelemetryCollector, docsConfiguration, options2) {
142
+ constructor(schemaValidator, openTelemetryCollector, options2) {
134
143
  super(
135
144
  schemaValidator,
136
145
  express2(),
@@ -138,9 +147,10 @@ var Application = class extends ForklaunchExpressLikeApplication {
138
147
  contentParse(options2),
139
148
  enrichResponseTransmission
140
149
  ],
141
- openTelemetryCollector
150
+ openTelemetryCollector,
151
+ options2
142
152
  );
143
- this.docsConfiguration = docsConfiguration;
153
+ this.docsConfiguration = options2?.docs;
144
154
  }
145
155
  listen(...args) {
146
156
  const port = typeof args[0] === "number" ? args[0] : Number(process.env.PORT);
@@ -621,13 +631,8 @@ var unsubscribe = (schemaValidator, path, contractDetails, ...handlers2) => {
621
631
  };
622
632
 
623
633
  // index.ts
624
- function forklaunchExpress(schemaValidator, openTelemetryCollector, docsConfiguration, options2) {
625
- return new Application(
626
- schemaValidator,
627
- openTelemetryCollector,
628
- docsConfiguration,
629
- options2
630
- );
634
+ function forklaunchExpress(schemaValidator, openTelemetryCollector, options2) {
635
+ return new Application(schemaValidator, openTelemetryCollector, options2);
631
636
  }
632
637
  function forklaunchRouter(basePath, schemaValidator, openTelemetryCollector, options2) {
633
638
  const router = new Router(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/express",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "Forklaunch framework for express.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -25,30 +25,30 @@
25
25
  "lib/**"
26
26
  ],
27
27
  "dependencies": {
28
- "@scalar/express-api-reference": "^0.8.1",
29
- "@types/multer": "^1.4.12",
28
+ "@scalar/express-api-reference": "^0.8.3",
29
+ "@types/multer": "^1.4.13",
30
30
  "body-parser": "^2.2.0",
31
31
  "busboy": "^1.6.0",
32
32
  "cors": "^2.8.5",
33
33
  "express": "^5.1.0",
34
- "multer": "2.0.0",
34
+ "multer": "2.0.1",
35
35
  "qs": "^6.14.0",
36
36
  "swagger-ui-express": "^5.0.1",
37
- "@forklaunch/common": "0.3.5",
38
- "@forklaunch/core": "0.8.7",
39
- "@forklaunch/validator": "0.6.5"
37
+ "@forklaunch/common": "0.3.7",
38
+ "@forklaunch/core": "0.8.9",
39
+ "@forklaunch/validator": "0.6.7"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@eslint/js": "^9.28.0",
43
- "@types/body-parser": "^1.19.5",
43
+ "@types/body-parser": "^1.19.6",
44
44
  "@types/busboy": "^1.5.4",
45
- "@types/cors": "^2.8.18",
46
- "@types/express": "^5.0.2",
45
+ "@types/cors": "^2.8.19",
46
+ "@types/express": "^5.0.3",
47
47
  "@types/express-serve-static-core": "^5.0.6",
48
48
  "@types/jest": "^29.5.14",
49
49
  "@types/qs": "^6.14.0",
50
50
  "@types/swagger-ui-express": "^4.1.8",
51
- "@typescript/native-preview": "7.0.0-dev.20250601.1",
51
+ "@typescript/native-preview": "7.0.0-dev.20250609.1",
52
52
  "jest": "^29.7.0",
53
53
  "kill-port-process": "^3.2.1",
54
54
  "prettier": "^3.5.3",
@@ -57,7 +57,7 @@
57
57
  "tsup": "^8.5.0",
58
58
  "typedoc": "^0.28.5",
59
59
  "typescript": "^5.8.3",
60
- "typescript-eslint": "^8.33.0"
60
+ "typescript-eslint": "^8.33.1"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsgo --noEmit && tsup index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",