@forklaunch/hyper-express 0.3.5 → 0.3.7
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 +4 -3
- package/lib/index.d.ts +4 -3
- package/lib/index.js +34 -23
- package/lib/index.mjs +34 -23
- package/package.json +7 -7
package/lib/index.d.mts
CHANGED
@@ -2,7 +2,7 @@ import * as _forklaunch_hyper_express_fork from '@forklaunch/hyper-express-fork'
|
|
2
2
|
import { Server, MiddlewareHandler, Request, Response, MiddlewareNext, Router as Router$1 } from '@forklaunch/hyper-express-fork';
|
3
3
|
export { MiddlewareNext as NextFunction, Request, Response } from '@forklaunch/hyper-express-fork';
|
4
4
|
import * as _forklaunch_core_http from '@forklaunch/core/http';
|
5
|
-
import { ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
|
5
|
+
import { ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, DocsConfiguration, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
|
6
6
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
7
7
|
import * as uWebsockets from 'uWebSockets.js';
|
8
8
|
export { ParsedQs } from 'qs';
|
@@ -13,12 +13,13 @@ export { ParsedQs } from 'qs';
|
|
13
13
|
* @template SV - A type that extends AnySchemaValidator.
|
14
14
|
*/
|
15
15
|
declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Server, MiddlewareHandler, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext> {
|
16
|
+
private readonly docsConfiguration?;
|
16
17
|
/**
|
17
18
|
* Creates an instance of the Application class.
|
18
19
|
*
|
19
20
|
* @param {SV} schemaValidator - The schema validator.
|
20
21
|
*/
|
21
|
-
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition
|
22
|
+
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration | undefined);
|
22
23
|
/**
|
23
24
|
* Starts the server and sets up Swagger documentation.
|
24
25
|
*
|
@@ -46,7 +47,7 @@ type App<SV extends AnySchemaValidator> = Application<SV>;
|
|
46
47
|
* @param {SV} schemaValidator - The schema validator.
|
47
48
|
* @returns {Application<SV>} - The new application instance.
|
48
49
|
*/
|
49
|
-
declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition
|
50
|
+
declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration): Application<SV>;
|
50
51
|
/**
|
51
52
|
* Creates a new instance of Router with the given base path and schema validator.
|
52
53
|
*
|
package/lib/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ import * as _forklaunch_hyper_express_fork from '@forklaunch/hyper-express-fork'
|
|
2
2
|
import { Server, MiddlewareHandler, Request, Response, MiddlewareNext, Router as Router$1 } from '@forklaunch/hyper-express-fork';
|
3
3
|
export { MiddlewareNext as NextFunction, Request, Response } from '@forklaunch/hyper-express-fork';
|
4
4
|
import * as _forklaunch_core_http from '@forklaunch/core/http';
|
5
|
-
import { ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
|
5
|
+
import { ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, DocsConfiguration, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
|
6
6
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
7
7
|
import * as uWebsockets from 'uWebSockets.js';
|
8
8
|
export { ParsedQs } from 'qs';
|
@@ -13,12 +13,13 @@ export { ParsedQs } from 'qs';
|
|
13
13
|
* @template SV - A type that extends AnySchemaValidator.
|
14
14
|
*/
|
15
15
|
declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Server, MiddlewareHandler, Request<Record<string, unknown>>, Response<Record<string, unknown>>, MiddlewareNext> {
|
16
|
+
private readonly docsConfiguration?;
|
16
17
|
/**
|
17
18
|
* Creates an instance of the Application class.
|
18
19
|
*
|
19
20
|
* @param {SV} schemaValidator - The schema validator.
|
20
21
|
*/
|
21
|
-
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition
|
22
|
+
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration | undefined);
|
22
23
|
/**
|
23
24
|
* Starts the server and sets up Swagger documentation.
|
24
25
|
*
|
@@ -46,7 +47,7 @@ type App<SV extends AnySchemaValidator> = Application<SV>;
|
|
46
47
|
* @param {SV} schemaValidator - The schema validator.
|
47
48
|
* @returns {Application<SV>} - The new application instance.
|
48
49
|
*/
|
49
|
-
declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition
|
50
|
+
declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration): Application<SV>;
|
50
51
|
/**
|
51
52
|
* Creates a new instance of Router with the given base path and schema validator.
|
52
53
|
*
|
package/lib/index.js
CHANGED
@@ -166,8 +166,9 @@ var Application = class extends import_http11.ForklaunchExpressLikeApplication {
|
|
166
166
|
*
|
167
167
|
* @param {SV} schemaValidator - The schema validator.
|
168
168
|
*/
|
169
|
-
constructor(schemaValidator, openTelemetryCollector) {
|
169
|
+
constructor(schemaValidator, openTelemetryCollector, docsConfiguration) {
|
170
170
|
super(schemaValidator, new import_hyper_express_fork.Server(), openTelemetryCollector);
|
171
|
+
this.docsConfiguration = docsConfiguration;
|
171
172
|
}
|
172
173
|
async listen(arg0, arg1, arg2) {
|
173
174
|
if (typeof arg0 === "number") {
|
@@ -180,35 +181,41 @@ var Application = class extends import_http11.ForklaunchExpressLikeApplication {
|
|
180
181
|
).send(
|
181
182
|
`Internal server error:
|
182
183
|
|
183
|
-
${(0, import_http11.isForklaunchRequest)(req) ? req.context.correlationId : "No correlation ID"}`
|
184
|
+
Correlation id: ${(0, import_http11.isForklaunchRequest)(req) ? req.context.correlationId : "No correlation ID"}`
|
184
185
|
);
|
185
186
|
(0, import_http11.logger)("error").error(err.stack ?? err.message, {
|
186
187
|
[import_http11.ATTR_HTTP_RESPONSE_STATUS_CODE]: res.statusCode ?? 500
|
187
188
|
});
|
188
189
|
});
|
189
|
-
this.
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
190
|
+
if (this.docsConfiguration == null || this.docsConfiguration.type === "scalar") {
|
191
|
+
this.internal.use(
|
192
|
+
`/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`,
|
193
|
+
(0, import_express_api_reference.apiReference)({
|
194
|
+
spec: {
|
195
|
+
content: (0, import_http11.generateSwaggerDocument)(
|
196
|
+
this.schemaValidator,
|
197
|
+
port,
|
198
|
+
this.routers
|
199
|
+
)
|
200
|
+
},
|
201
|
+
...this.docsConfiguration
|
202
|
+
})
|
203
|
+
);
|
204
|
+
} else if (this.docsConfiguration.type === "swagger") {
|
205
|
+
const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`;
|
206
|
+
this.internal.use(swaggerPath, swaggerRedirect(swaggerPath));
|
207
|
+
this.internal.get(
|
208
|
+
`${swaggerPath}/*`,
|
209
|
+
swagger(
|
210
|
+
swaggerPath,
|
211
|
+
(0, import_http11.generateSwaggerDocument)(
|
194
212
|
this.schemaValidator,
|
195
213
|
port,
|
196
214
|
this.routers
|
197
215
|
)
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
})
|
202
|
-
);
|
203
|
-
const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${"/swagger"}`;
|
204
|
-
this.internal.use(swaggerPath, swaggerRedirect(swaggerPath));
|
205
|
-
this.internal.get(
|
206
|
-
`${swaggerPath}/*`,
|
207
|
-
swagger(
|
208
|
-
swaggerPath,
|
209
|
-
(0, import_http11.generateSwaggerDocument)(this.schemaValidator, port, this.routers)
|
210
|
-
)
|
211
|
-
);
|
216
|
+
)
|
217
|
+
);
|
218
|
+
}
|
212
219
|
if (arg1 && typeof arg1 === "string") {
|
213
220
|
return this.internal.listen(port, arg1, arg2);
|
214
221
|
} else if (arg1 && typeof arg1 === "function") {
|
@@ -354,8 +361,12 @@ var Router = class extends import_http13.ForklaunchExpressLikeRouter {
|
|
354
361
|
};
|
355
362
|
|
356
363
|
// index.ts
|
357
|
-
function forklaunchExpress(schemaValidator, openTelemetryCollector) {
|
358
|
-
return new Application(
|
364
|
+
function forklaunchExpress(schemaValidator, openTelemetryCollector, docsConfiguration) {
|
365
|
+
return new Application(
|
366
|
+
schemaValidator,
|
367
|
+
openTelemetryCollector,
|
368
|
+
docsConfiguration
|
369
|
+
);
|
359
370
|
}
|
360
371
|
function forklaunchRouter(basePath, schemaValidator, openTelemetryCollector) {
|
361
372
|
const router = new Router(basePath, schemaValidator, openTelemetryCollector);
|
package/lib/index.mjs
CHANGED
@@ -156,8 +156,9 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
156
156
|
*
|
157
157
|
* @param {SV} schemaValidator - The schema validator.
|
158
158
|
*/
|
159
|
-
constructor(schemaValidator, openTelemetryCollector) {
|
159
|
+
constructor(schemaValidator, openTelemetryCollector, docsConfiguration) {
|
160
160
|
super(schemaValidator, new Server(), openTelemetryCollector);
|
161
|
+
this.docsConfiguration = docsConfiguration;
|
161
162
|
}
|
162
163
|
async listen(arg0, arg1, arg2) {
|
163
164
|
if (typeof arg0 === "number") {
|
@@ -170,35 +171,41 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
170
171
|
).send(
|
171
172
|
`Internal server error:
|
172
173
|
|
173
|
-
${isForklaunchRequest(req) ? req.context.correlationId : "No correlation ID"}`
|
174
|
+
Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No correlation ID"}`
|
174
175
|
);
|
175
176
|
logger("error").error(err.stack ?? err.message, {
|
176
177
|
[ATTR_HTTP_RESPONSE_STATUS_CODE]: res.statusCode ?? 500
|
177
178
|
});
|
178
179
|
});
|
179
|
-
this.
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
if (this.docsConfiguration == null || this.docsConfiguration.type === "scalar") {
|
181
|
+
this.internal.use(
|
182
|
+
`/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`,
|
183
|
+
apiReference({
|
184
|
+
spec: {
|
185
|
+
content: generateSwaggerDocument(
|
186
|
+
this.schemaValidator,
|
187
|
+
port,
|
188
|
+
this.routers
|
189
|
+
)
|
190
|
+
},
|
191
|
+
...this.docsConfiguration
|
192
|
+
})
|
193
|
+
);
|
194
|
+
} else if (this.docsConfiguration.type === "swagger") {
|
195
|
+
const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${process.env.DOCS_PATH ?? "/docs"}`;
|
196
|
+
this.internal.use(swaggerPath, swaggerRedirect(swaggerPath));
|
197
|
+
this.internal.get(
|
198
|
+
`${swaggerPath}/*`,
|
199
|
+
swagger(
|
200
|
+
swaggerPath,
|
201
|
+
generateSwaggerDocument(
|
184
202
|
this.schemaValidator,
|
185
203
|
port,
|
186
204
|
this.routers
|
187
205
|
)
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
})
|
192
|
-
);
|
193
|
-
const swaggerPath = `/api/${process.env.VERSION ?? "v1"}${"/swagger"}`;
|
194
|
-
this.internal.use(swaggerPath, swaggerRedirect(swaggerPath));
|
195
|
-
this.internal.get(
|
196
|
-
`${swaggerPath}/*`,
|
197
|
-
swagger(
|
198
|
-
swaggerPath,
|
199
|
-
generateSwaggerDocument(this.schemaValidator, port, this.routers)
|
200
|
-
)
|
201
|
-
);
|
206
|
+
)
|
207
|
+
);
|
208
|
+
}
|
202
209
|
if (arg1 && typeof arg1 === "string") {
|
203
210
|
return this.internal.listen(port, arg1, arg2);
|
204
211
|
} else if (arg1 && typeof arg1 === "function") {
|
@@ -350,8 +357,12 @@ var Router = class extends ForklaunchExpressLikeRouter {
|
|
350
357
|
};
|
351
358
|
|
352
359
|
// index.ts
|
353
|
-
function forklaunchExpress(schemaValidator, openTelemetryCollector) {
|
354
|
-
return new Application(
|
360
|
+
function forklaunchExpress(schemaValidator, openTelemetryCollector, docsConfiguration) {
|
361
|
+
return new Application(
|
362
|
+
schemaValidator,
|
363
|
+
openTelemetryCollector,
|
364
|
+
docsConfiguration
|
365
|
+
);
|
355
366
|
}
|
356
367
|
function forklaunchRouter(basePath, schemaValidator, openTelemetryCollector) {
|
357
368
|
const router = new Router(basePath, schemaValidator, openTelemetryCollector);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@forklaunch/hyper-express",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.7",
|
4
4
|
"description": "Forklaunch framework for hyper-express.",
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
6
6
|
"bugs": {
|
@@ -26,17 +26,17 @@
|
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
28
|
"@forklaunch/hyper-express-fork": "^6.17.30",
|
29
|
-
"@scalar/express-api-reference": "^0.4.
|
29
|
+
"@scalar/express-api-reference": "^0.4.193",
|
30
30
|
"cors": "^2.8.5",
|
31
31
|
"live-directory": "^3.0.3",
|
32
32
|
"openapi3-ts": "^4.4.0",
|
33
33
|
"qs": "^6.14.0",
|
34
|
-
"swagger-ui-dist": "^5.20.
|
34
|
+
"swagger-ui-dist": "^5.20.1",
|
35
35
|
"swagger-ui-express": "^5.0.1",
|
36
36
|
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.44.0",
|
37
|
-
"@forklaunch/
|
38
|
-
"@forklaunch/
|
39
|
-
"@forklaunch/validator": "0.4.
|
37
|
+
"@forklaunch/core": "0.5.6",
|
38
|
+
"@forklaunch/common": "0.2.4",
|
39
|
+
"@forklaunch/validator": "0.4.7"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
42
|
"@eslint/js": "^9.22.0",
|
@@ -53,7 +53,7 @@
|
|
53
53
|
"tsup": "^8.4.0",
|
54
54
|
"tsx": "^4.19.3",
|
55
55
|
"typescript": "^5.8.2",
|
56
|
-
"typescript-eslint": "^8.26.
|
56
|
+
"typescript-eslint": "^8.26.1"
|
57
57
|
},
|
58
58
|
"scripts": {
|
59
59
|
"build": "tsc --noEmit && tsup index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean",
|