@kalutskii/foundation 0.7.10 → 0.7.11
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.ts +15 -4
- package/dist/index.js +25 -23
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,10 +20,21 @@ declare function sqlWhere(table: unknown, where: Record<string, unknown>): SQL;
|
|
|
20
20
|
declare const onHandlerError: ErrorHandler;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Options controlling which request details the Hono logger may expose.
|
|
24
|
+
* Secure mode excludes query parameters and body content from log output.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
type HonoLoggingOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Prevents query parameters and request bodies from being read or logged.
|
|
29
|
+
* Defaults to `false`, preserving detailed request logging.
|
|
30
|
+
*/
|
|
31
|
+
secure?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Creates middleware that logs request metadata and an optional body preview.
|
|
35
|
+
* Multipart bodies remain unread, while secure mode omits all sensitive input details.
|
|
36
|
+
*/
|
|
37
|
+
declare function honoLoggingHandler(options?: HonoLoggingOptions): MiddlewareHandler;
|
|
27
38
|
|
|
28
39
|
declare const SUCCESS_STATUS_CODES: readonly [200, 201, 202, 307];
|
|
29
40
|
declare const EXCEPTION_STATUS_CODES: readonly [400, 401, 403, 404, 405, 409, 500];
|
|
@@ -832,4 +843,4 @@ declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>
|
|
|
832
843
|
*/
|
|
833
844
|
declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
834
845
|
|
|
835
|
-
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, DEFAULT_UPLOAD_MAX_FILE_SIZE, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type FileFormat, type FileFormatConfig, type HonoFileRespondOptions, type HonoRespondOptions, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, type ReplaceDotsWithUnderscores, SUCCESS_STATUS_CODES, type Simplify, type StringEnumRecord, type SuccessStatusCode, type UploadFilesValidationOptions, type UploadFilesValidationResult, type UploadPreset, type UploadValidationError, type ZodBulkExcludeSelection, type ZodBulkIncludeSelection, type ZodBulkSelection, ZodJWTService, type ZodPaginationOptions, type ZodSearchSchemaOptions, type ZodUploadFileSchemaOptions, asQuery, createStringEnumRecord, createUploadAccept, createZodSearchWhereSchema, defineUploadPreset, documentUploadPreset, failure, fetchAndThrow, fetchSafely, fileFormat, fileFormatsArray, fileFormatsConfig, fileFormatsRecord, fileRespond, formatTime, generateRandomString, getColoredHTTPStatus, getFileExtension, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, imageUploadPreset, isFileExtensionSupported, isFileFormatSupported, isFileMimeTypeSupported, isPlainObject, log, matchesMimeType, measureExecutionTime, normalizeFileExtension, onHandlerError, parseQueryValue, respond, safeExecute, sqlWhere, success, uploadValidationError, uploadValidationErrorsArray, uploadValidationErrorsRecord, validateUploadFile, validateUploadFiles, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchQuerySchema, zodSearchSchema, zodUploadFileSchema };
|
|
846
|
+
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, DEFAULT_UPLOAD_MAX_FILE_SIZE, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type FileFormat, type FileFormatConfig, type HonoFileRespondOptions, type HonoLoggingOptions, type HonoRespondOptions, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, type ReplaceDotsWithUnderscores, SUCCESS_STATUS_CODES, type Simplify, type StringEnumRecord, type SuccessStatusCode, type UploadFilesValidationOptions, type UploadFilesValidationResult, type UploadPreset, type UploadValidationError, type ZodBulkExcludeSelection, type ZodBulkIncludeSelection, type ZodBulkSelection, ZodJWTService, type ZodPaginationOptions, type ZodSearchSchemaOptions, type ZodUploadFileSchemaOptions, asQuery, createStringEnumRecord, createUploadAccept, createZodSearchWhereSchema, defineUploadPreset, documentUploadPreset, failure, fetchAndThrow, fetchSafely, fileFormat, fileFormatsArray, fileFormatsConfig, fileFormatsRecord, fileRespond, formatTime, generateRandomString, getColoredHTTPStatus, getFileExtension, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, imageUploadPreset, isFileExtensionSupported, isFileFormatSupported, isFileMimeTypeSupported, isPlainObject, log, matchesMimeType, measureExecutionTime, normalizeFileExtension, onHandlerError, parseQueryValue, respond, safeExecute, sqlWhere, success, uploadValidationError, uploadValidationErrorsArray, uploadValidationErrorsRecord, validateUploadFile, validateUploadFiles, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchQuerySchema, zodSearchSchema, zodUploadFileSchema };
|
package/dist/index.js
CHANGED
|
@@ -119,29 +119,31 @@ var onHandlerError = (error, c) => {
|
|
|
119
119
|
|
|
120
120
|
// src/hono/hono.logging.ts
|
|
121
121
|
import { blue as blue2, bold, dim as dim2, white as white2 } from "kleur/colors";
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
122
|
+
function honoLoggingHandler(options = {}) {
|
|
123
|
+
return async (c, next) => {
|
|
124
|
+
const searchParams = new URL(c.req.url).searchParams.toString();
|
|
125
|
+
const body = c.req.header("content-type")?.includes("multipart/form-data") ? (
|
|
126
|
+
// Multipart content remains unread to avoid buffering uploaded files;
|
|
127
|
+
// The placeholder records its presence without exposing any fields;
|
|
128
|
+
"[multipart]"
|
|
129
|
+
) : (
|
|
130
|
+
// Other bodies are read from a clone and normalized for one-line output;
|
|
131
|
+
// The original request stream remains available to downstream handlers;
|
|
132
|
+
(await c.req.raw.clone().text()).replaceAll(/\s+/g, " ").trim()
|
|
133
|
+
);
|
|
134
|
+
const bodyPreview = body.length > 60 ? `${body.slice(0, 30)}\u2026${body.slice(-30)}` : body;
|
|
135
|
+
const startTime = performance.now();
|
|
136
|
+
await next();
|
|
137
|
+
const duration = Math.round(performance.now() - startTime);
|
|
138
|
+
const coloredMethod = bold(blue2(c.req.method.padEnd(4)));
|
|
139
|
+
const coloredStatus = getColoredHTTPStatus(c.res.status)(String(c.res.status).padEnd(4));
|
|
140
|
+
const coloredTime = dim2(`${duration}ms`.padStart(6));
|
|
141
|
+
const coloredPath = white2(c.req.path.padEnd(32));
|
|
142
|
+
const coloredSearchParams = options.secure ? "" : dim2(` (${searchParams})`);
|
|
143
|
+
const coloredBody = options.secure ? "" : dim2(` ${bodyPreview}`);
|
|
144
|
+
log.info(`${coloredMethod} ${coloredStatus} ${coloredTime} ${coloredPath}${coloredSearchParams}${coloredBody}`, "hono");
|
|
145
|
+
};
|
|
146
|
+
}
|
|
145
147
|
|
|
146
148
|
// src/hono/hono.respond.ts
|
|
147
149
|
function respond(c, options) {
|