@kalutskii/foundation 0.7.3 → 0.7.5

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/README.md CHANGED
@@ -71,7 +71,7 @@ Independent modules should remain independent instead of introducing artificial
71
71
  7. A reusable abstraction belongs to the lowest layer that can own it without knowing its consumers.
72
72
 
73
73
  A dependency that appears only in generated declarations is still a real dependency and must be reviewed.
74
- For example, a generic Zod type importing `Simplify` from Drizzle would violate the hierarchy even at runtime zero.
74
+ For example, a generic Zod type importing `Simplify` from Drizzle would violate the hierarchy even with no runtime cost.
75
75
 
76
76
  ### Responsibility boundaries
77
77
 
package/dist/index.js CHANGED
@@ -108,6 +108,15 @@ import { blue as blue2, bold, dim as dim2, white as white2 } from "kleur/colors"
108
108
  var honoLoggingHandler = async (c, next) => {
109
109
  const requestUrl = new URL(c.req.url);
110
110
  const searchParams = requestUrl.searchParams.toString();
111
+ const body = c.req.header("content-type")?.includes("multipart/form-data") ? (
112
+ // If the request is multipart/form-data, we avoid reading the body
113
+ // to prevent consuming the stream, and instead log a placeholder.
114
+ "[multipart]"
115
+ ) : (
116
+ // Otherwise, we read the request body as text and normalize whitespace.
117
+ (await c.req.raw.clone().text()).replaceAll(/\s+/g, " ").trim()
118
+ );
119
+ const bodyPreview = body.length > 100 ? `${body.slice(0, 50)}\u2026${body.slice(-50)}` : body;
111
120
  const startTime = performance.now();
112
121
  await next();
113
122
  const duration = Math.round(performance.now() - startTime);
@@ -116,7 +125,8 @@ var honoLoggingHandler = async (c, next) => {
116
125
  const coloredTime = dim2(`${duration}ms`.padStart(6));
117
126
  const coloredPath = white2(c.req.path.padEnd(44));
118
127
  const coloredSearchParams = searchParams ? dim2(` (${searchParams})`) : "";
119
- log.info(`${coloredMethod} ${coloredStatus} ${coloredTime} ${coloredPath}${coloredSearchParams}`, "hono");
128
+ const coloredBody = bodyPreview ? dim2(` ${bodyPreview}`) : "";
129
+ log.info(`${coloredMethod} ${coloredStatus} ${coloredTime} ${coloredPath}${coloredSearchParams}${coloredBody}`, "hono");
120
130
  };
121
131
 
122
132
  // src/hono/hono.respond.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {