@vercube/core 0.0.31 → 0.0.33
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/dist/index.d.mts +3 -3
- package/dist/index.mjs +9 -9
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1127,12 +1127,12 @@ declare class StandardSchemaValidationProvider implements ValidationProvider {
|
|
|
1127
1127
|
validate(schema: ValidationTypes.Schema, data: ValidationTypes.Input): ValidationTypes.Result | Promise<ValidationTypes.Result>;
|
|
1128
1128
|
}
|
|
1129
1129
|
//#endregion
|
|
1130
|
-
//#region src/Services/RequestContext
|
|
1130
|
+
//#region src/Services/Router/RequestContext.d.ts
|
|
1131
1131
|
/**
|
|
1132
1132
|
* Request context storage using AsyncLocalStorage.
|
|
1133
1133
|
* This allows storing request-specific data that is automatically cleaned up after the request completes.
|
|
1134
1134
|
*/
|
|
1135
|
-
declare class
|
|
1135
|
+
declare class RequestContext {
|
|
1136
1136
|
/** The storage for the request context */
|
|
1137
1137
|
private readonly fStorage;
|
|
1138
1138
|
/**
|
|
@@ -1695,4 +1695,4 @@ declare function initializeMetadataMethod(target: any, propertyName: string): Me
|
|
|
1695
1695
|
*/
|
|
1696
1696
|
declare function initializeMetadata(target: any): MetadataTypes.Ctx;
|
|
1697
1697
|
//#endregion
|
|
1698
|
-
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, ConfigTypes, Connect, Controller, CreateAppOptions, DeepPartial, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers, HooksService, HooksTypes, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MaybePromise, MetadataResolver, MetadataTypes, MethodNotAllowedError, Middleware$1 as Middleware, MiddlewareOptions, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request$1 as Request,
|
|
1698
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, ConfigTypes, Connect, Controller, CreateAppOptions, DeepPartial, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers, HooksService, HooksTypes, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MaybePromise, MetadataResolver, MetadataTypes, MethodNotAllowedError, Middleware$1 as Middleware, MiddlewareOptions, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request$1 as Request, RequestContext, Response$1 as Response, Router, RouterTypes, RuntimeConfig$1 as RuntimeConfig, SetHeader, StandardSchemaValidationProvider, Status, Trace, UnauthorizedError, ValidationProvider, ValidationTypes, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -144,7 +144,7 @@ var BadRequestError = class BadRequestError extends HttpError {
|
|
|
144
144
|
* - Throws BadRequestError for malformed JSON
|
|
145
145
|
*/
|
|
146
146
|
async function resolveRequestBody(event) {
|
|
147
|
-
const text = await event.request.text();
|
|
147
|
+
const text = await event.request.clone().text();
|
|
148
148
|
if (!text) return;
|
|
149
149
|
try {
|
|
150
150
|
return JSON.parse(text);
|
|
@@ -334,12 +334,12 @@ var GlobalMiddlewareRegistry = class {
|
|
|
334
334
|
};
|
|
335
335
|
|
|
336
336
|
//#endregion
|
|
337
|
-
//#region src/Services/RequestContext
|
|
337
|
+
//#region src/Services/Router/RequestContext.ts
|
|
338
338
|
/**
|
|
339
339
|
* Request context storage using AsyncLocalStorage.
|
|
340
340
|
* This allows storing request-specific data that is automatically cleaned up after the request completes.
|
|
341
341
|
*/
|
|
342
|
-
var
|
|
342
|
+
var RequestContext = class {
|
|
343
343
|
/** The storage for the request context */
|
|
344
344
|
fStorage;
|
|
345
345
|
/**
|
|
@@ -375,7 +375,7 @@ var RequestContextService = class {
|
|
|
375
375
|
*/
|
|
376
376
|
set(key, value) {
|
|
377
377
|
const context = this.fStorage.getStore();
|
|
378
|
-
if (!context) throw new Error("
|
|
378
|
+
if (!context) throw new Error("RequestContext.set() called outside of request context. The context is automatically initialized by RequestHandler.");
|
|
379
379
|
context.set(key, value);
|
|
380
380
|
}
|
|
381
381
|
/**
|
|
@@ -387,7 +387,7 @@ var RequestContextService = class {
|
|
|
387
387
|
*/
|
|
388
388
|
get(key) {
|
|
389
389
|
const context = this.fStorage.getStore();
|
|
390
|
-
if (!context) throw new Error("
|
|
390
|
+
if (!context) throw new Error("RequestContext.get() called outside of request context. The context is automatically initialized by RequestHandler.");
|
|
391
391
|
return context.get(key);
|
|
392
392
|
}
|
|
393
393
|
/**
|
|
@@ -615,8 +615,8 @@ var RequestHandler = class {
|
|
|
615
615
|
* @private
|
|
616
616
|
*/
|
|
617
617
|
async runWithContext(fn) {
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
618
|
+
const requestContext = this.gContainer.getOptional(RequestContext);
|
|
619
|
+
if (requestContext) return requestContext.run(fn);
|
|
620
620
|
return fn();
|
|
621
621
|
}
|
|
622
622
|
/**
|
|
@@ -1412,7 +1412,7 @@ function createContainer(config) {
|
|
|
1412
1412
|
container.bind(RequestHandler);
|
|
1413
1413
|
container.bind(RuntimeConfig);
|
|
1414
1414
|
container.bind(GlobalMiddlewareRegistry);
|
|
1415
|
-
container.bind(
|
|
1415
|
+
container.bind(RequestContext);
|
|
1416
1416
|
container.bind(ValidationProvider, StandardSchemaValidationProvider);
|
|
1417
1417
|
return container;
|
|
1418
1418
|
}
|
|
@@ -3150,4 +3150,4 @@ let HttpStatusCode = /* @__PURE__ */ function(HttpStatusCode$1) {
|
|
|
3150
3150
|
}({});
|
|
3151
3151
|
|
|
3152
3152
|
//#endregion
|
|
3153
|
-
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request,
|
|
3153
|
+
export { App, BadRequestError, BaseMiddleware, BasePlugin, Body, Connect, Controller, Delete, ErrorHandlerProvider, FastResponse, ForbiddenError, Get, GlobalMiddlewareRegistry, HTTPStatus, Head, Header, Headers$1 as Headers, HooksService, HttpError, HttpServer, HttpStatusCode, InternalServerError, Listen, MetadataResolver, MethodNotAllowedError, Middleware, MultipartFormData, NotAcceptableError, NotFoundError, Options, Param, Patch, Post, Put, QueryParam, QueryParams, Redirect, Request, RequestContext, Response$1 as Response, Router, RuntimeConfig, SetHeader, StandardSchemaValidationProvider, Status, Trace, UnauthorizedError, ValidationProvider, createApp, createMetadataCtx, createMetadataMethod, defineConfig, initializeMetadata, initializeMetadataMethod, loadVercubeConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"description": "Core module for Vercube framework",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"pathe": "2.0.3",
|
|
29
29
|
"rou3": "0.7.9",
|
|
30
30
|
"srvx": "0.9.4",
|
|
31
|
-
"@vercube/di": "0.0.
|
|
32
|
-
"@vercube/logger": "0.0.
|
|
31
|
+
"@vercube/di": "0.0.33",
|
|
32
|
+
"@vercube/logger": "0.0.33"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"rolldown": "1.0.0-beta.45",
|