Comparing version 0.5.9 to 0.5.10
@@ -15,2 +15,3 @@ /// <reference types="@cloudflare/workers-types" /> | ||
private _pretty; | ||
private _prettySpace; | ||
render: (template: string, params?: object, options?: object) => Promise<Response>; | ||
@@ -25,3 +26,3 @@ notFound: () => Response | Promise<Response>; | ||
status(number: number): void; | ||
pretty(prettyJSON: boolean): void; | ||
pretty(prettyJSON: boolean, space?: number): void; | ||
newResponse(data: Data, init?: ResponseInit): Response; | ||
@@ -28,0 +29,0 @@ body(data: Data, status?: number, headers?: Headers): Response; |
@@ -8,2 +8,3 @@ "use strict"; | ||
constructor(req, opts) { | ||
this._prettySpace = 2; | ||
this.req = req; | ||
@@ -38,4 +39,5 @@ if (opts) { | ||
} | ||
pretty(prettyJSON) { | ||
pretty(prettyJSON, space = 2) { | ||
this._pretty = prettyJSON; | ||
this._prettySpace = space; | ||
} | ||
@@ -77,3 +79,5 @@ newResponse(data, init = {}) { | ||
} | ||
const body = this._pretty ? JSON.stringify(object, null, 2) : JSON.stringify(object); | ||
const body = this._pretty | ||
? JSON.stringify(object, null, this._prettySpace) | ||
: JSON.stringify(object); | ||
headers['Content-Type'] || (headers['Content-Type'] = 'application/json; charset=UTF-8'); | ||
@@ -80,0 +84,0 @@ return this.body(body, status, headers); |
{ | ||
"name": "hono", | ||
"version": "0.5.9", | ||
"version": "0.5.10", | ||
"description": "[炎] Ultrafast web framework for Cloudflare Workers.", | ||
@@ -28,2 +28,3 @@ "main": "dist/index.js", | ||
"./powered-by": "./dist/middleware/powered-by/powered-by.js", | ||
"./pretty-json": "./dist/middleware/pretty-json/pretty-json.js", | ||
"./serve-static": "./dist/middleware/serve-static/serve-static.js", | ||
@@ -65,2 +66,5 @@ "./router/trie-router": "./dist/router/trie-router/router.js", | ||
], | ||
"pretty-json": [ | ||
"./dist/middleware/pretty-json/pretty-json.d.ts" | ||
], | ||
"serve-static": [ | ||
@@ -67,0 +71,0 @@ "./dist/middleware/serve-static/serve-static.d.ts" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85914
65
1960