@h3ravel/router 2.1.4 → 2.2.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 (2) hide show
  1. package/dist/index.js +10 -2
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -3302,8 +3302,16 @@ var Router = class Router extends mix(IRouter, MacroableClass, Magic) {
3302
3302
  */
3303
3303
  static toResponse(request, response) {
3304
3304
  if (response instanceof IResponsable) response = response.toResponse(request);
3305
- if (response instanceof Stringable || typeof response === "string") response = new Response(request.app, response.toString(), 200, { "Content-Type": "text/html" });
3306
- else if (!(response instanceof IResponse) && !(response instanceof Response)) response = new JsonResponse(request.app, response);
3305
+ const eventResponse = request.getEvent().res;
3306
+ const status = eventResponse.status;
3307
+ const statusText = eventResponse.statusText;
3308
+ const headers = Object.fromEntries(eventResponse.headers.entries());
3309
+ if (response instanceof Stringable || typeof response === "string") response = new Response(request.app, response.toString(), status, {
3310
+ ...headers,
3311
+ "Content-Type": "text/html"
3312
+ });
3313
+ else if (!(response instanceof IResponse) && !(response instanceof Response)) response = new JsonResponse(request.app, response, status, headers);
3314
+ if (statusText) response.setStatusCode(response.getStatusCode(), statusText);
3307
3315
  if (response.getStatusCode() === Response.codes.HTTP_NOT_MODIFIED) response.setNotModified();
3308
3316
  return response.prepare(request);
3309
3317
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h3ravel/router",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "description": "Route facade, decorators and controller system for H3ravel.",
5
5
  "h3ravel": {
6
6
  "providers": [
@@ -39,17 +39,17 @@
39
39
  "laravel"
40
40
  ],
41
41
  "peerDependencies": {
42
- "@h3ravel/database": "^11.18.4"
42
+ "@h3ravel/database": "^11.19.0"
43
43
  },
44
44
  "dependencies": {
45
45
  "h3": "2.0.1-rc.5",
46
- "@h3ravel/contracts": "^2.1.4",
47
- "@h3ravel/events": "^2.1.4",
46
+ "@h3ravel/contracts": "^2.2.0",
47
+ "@h3ravel/events": "^2.2.0",
48
48
  "@h3ravel/musket": "^1.29.0-alpha.15",
49
- "@h3ravel/http": "^11.18.4",
50
- "@h3ravel/shared": "^2.1.4",
51
- "@h3ravel/support": "^2.1.4",
52
- "@h3ravel/foundation": "^2.1.4",
49
+ "@h3ravel/http": "^11.19.0",
50
+ "@h3ravel/shared": "^2.2.0",
51
+ "@h3ravel/support": "^2.2.0",
52
+ "@h3ravel/foundation": "^2.2.0",
53
53
  "reflect-metadata": "^0.2.2"
54
54
  },
55
55
  "scripts": {