Socket
Socket
Sign inDemoInstall

hono

Package Overview
Dependencies
Maintainers
1
Versions
330
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hono - npm Package Compare versions

Comparing version 4.5.8 to 4.5.9

7

dist/cjs/middleware/pretty-json/index.js

@@ -24,9 +24,10 @@ "use strict";

module.exports = __toCommonJS(pretty_json_exports);
const prettyJSON = (options = { space: 2 }) => {
const prettyJSON = (options) => {
const targetQuery = options?.query ?? "pretty";
return async function prettyJSON2(c, next) {
const pretty = c.req.query("pretty") || c.req.query("pretty") === "";
const pretty = c.req.query(targetQuery) || c.req.query(targetQuery) === "";
await next();
if (pretty && c.res.headers.get("Content-Type")?.startsWith("application/json")) {
const obj = await c.res.json();
c.res = new Response(JSON.stringify(obj, null, options.space), c.res);
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
}

@@ -33,0 +34,0 @@ };

@@ -26,3 +26,3 @@ "use strict";

const { process, Deno } = globalThis;
const isNoColor = typeof process !== "undefined" ? "NO_COLOR" in process?.env : typeof Deno?.noColor === "boolean" ? Deno.noColor : false;
const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : typeof process !== "undefined" ? "NO_COLOR" in process?.env : false;
return !isNoColor;

@@ -29,0 +29,0 @@ }

// src/middleware/pretty-json/index.ts
var prettyJSON = (options = { space: 2 }) => {
var prettyJSON = (options) => {
const targetQuery = options?.query ?? "pretty";
return async function prettyJSON2(c, next) {
const pretty = c.req.query("pretty") || c.req.query("pretty") === "";
const pretty = c.req.query(targetQuery) || c.req.query(targetQuery) === "";
await next();
if (pretty && c.res.headers.get("Content-Type")?.startsWith("application/json")) {
const obj = await c.res.json();
c.res = new Response(JSON.stringify(obj, null, options.space), c.res);
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
}

@@ -10,0 +11,0 @@ };

@@ -249,3 +249,3 @@ import type { BaseMime } from '../utils/mime';

src?: string | undefined;
type?: string | undefined;
type?: StringLiteralUnion<BaseMime> | undefined;
width?: number | string | undefined;

@@ -370,3 +370,3 @@ }

sizes?: string | undefined;
type?: string | undefined;
type?: StringLiteralUnion<BaseMime> | undefined;
charSet?: string | undefined;

@@ -437,3 +437,3 @@ rel?: string | undefined;

name?: string | undefined;
type?: string | undefined;
type?: StringLiteralUnion<BaseMime> | undefined;
usemap?: string | undefined;

@@ -481,3 +481,6 @@ width?: number | string | undefined;

src?: string | undefined;
type?: string | undefined;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type
*/
type?: StringLiteralUnion<'' | 'text/javascript' | 'importmap' | 'module'> | undefined;
crossOrigin?: CrossOrigin;

@@ -501,2 +504,3 @@ fetchPriority?: string | undefined;

}
type MediaMime = BaseMime & (`image/${string}` | `audio/${string}` | `video/${string}`);
interface SourceHTMLAttributes extends HTMLAttributes {

@@ -508,3 +512,3 @@ height?: number | string | undefined;

srcset?: string | undefined;
type?: string | undefined;
type?: StringLiteralUnion<MediaMime> | undefined;
width?: number | string | undefined;

@@ -515,3 +519,6 @@ }

scoped?: boolean | undefined;
type?: string | undefined;
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#type
*/
type?: '' | 'text/css' | undefined;
href?: string | undefined;

@@ -518,0 +525,0 @@ precedence?: string | undefined;

@@ -6,5 +6,14 @@ /**

import type { MiddlewareHandler } from '../../types';
type prettyOptions = {
space: number;
};
interface PrettyOptions {
/**
* Number of spaces for indentation.
* @default 2
*/
space?: number;
/**
* Query conditions for when to Pretty.
* @default 'pretty'
*/
query?: string;
}
/**

@@ -15,4 +24,3 @@ * Pretty JSON Middleware for Hono.

*
* @param {prettyOptions} [options] - The options for the pretty JSON middleware.
* @param {number} [options.space=2] - Number of spaces for indentation.
* @param options - The options for the pretty JSON middleware.
* @returns {MiddlewareHandler} The middleware handler function.

@@ -30,3 +38,3 @@ *

*/
export declare const prettyJSON: (options?: prettyOptions) => MiddlewareHandler;
export declare const prettyJSON: (options?: PrettyOptions) => MiddlewareHandler;
export {};

@@ -5,2 +5,9 @@ /**

*/
/**
* Get whether color change on terminal is enabled or disabled.
* If `NO_COLOR` environment variable is set, this function returns `false`.
* @see {@link https://no-color.org/}
*
* @returns {boolean}
*/
export declare function getColorEnabled(): boolean;
// src/utils/color.ts
function getColorEnabled() {
const { process, Deno } = globalThis;
const isNoColor = typeof process !== "undefined" ? "NO_COLOR" in process?.env : typeof Deno?.noColor === "boolean" ? Deno.noColor : false;
const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : typeof process !== "undefined" ? "NO_COLOR" in process?.env : false;
return !isNoColor;

@@ -6,0 +6,0 @@ }

{
"name": "hono",
"version": "4.5.8",
"version": "4.5.9",
"description": "Web framework built on Web Standards",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc