@mattrika/server-utils 0.0.0-stage → 1.0.1

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.
@@ -0,0 +1,76 @@
1
+ import { z } from '@hono/zod-openapi';
2
+ import { ZodAny, ZodArray, ZodBoolean, ZodNumber, ZodObject, ZodOptional, ZodString } from 'zod';
3
+ export type ZodSchema = ZodObject<any> | ZodArray<ZodObject<any>>;
4
+ export declare const zResponsePagination: z.ZodObject<{
5
+ page: z.ZodNumber;
6
+ size: z.ZodNumber;
7
+ totalItems: z.ZodNumber;
8
+ totalPages: z.ZodNumber;
9
+ }, z.core.$strip>;
10
+ export type ResponsePagination = z.infer<typeof zResponsePagination>;
11
+ export declare function ApiResponse<T extends ZodSchema>(dataSchema: T, description: string): {
12
+ content: {
13
+ 'application/json': {
14
+ schema: ZodObject<{
15
+ data: T;
16
+ message: ZodString;
17
+ success: ZodBoolean;
18
+ error: ZodOptional<ZodAny>;
19
+ meta: ZodOptional<ZodAny>;
20
+ }>;
21
+ };
22
+ };
23
+ description: string;
24
+ };
25
+ export declare function ApiListResponse<T extends ZodSchema>(dataSchema: T, description: string): {
26
+ content: {
27
+ 'application/json': {
28
+ schema: ZodObject<{
29
+ data: T;
30
+ message: ZodString;
31
+ success: ZodBoolean;
32
+ error: ZodOptional<ZodAny>;
33
+ meta: ZodOptional<ZodAny>;
34
+ pagination: ZodObject<{
35
+ page: ZodNumber;
36
+ size: ZodNumber;
37
+ totalItems: ZodNumber;
38
+ totalPages: ZodNumber;
39
+ }>;
40
+ }>;
41
+ };
42
+ };
43
+ description: string;
44
+ };
45
+ export declare const zStreamResponse: z.ZodObject<{
46
+ body: z.ZodCustom<ReadableStream<any>, ReadableStream<any>>;
47
+ headers: z.ZodOptional<z.ZodObject<{
48
+ 'Content-Type': z.ZodDefault<z.ZodString>;
49
+ 'Content-Disposition': z.ZodString;
50
+ }, z.core.$strip>>;
51
+ }, z.core.$strip>;
52
+ export declare function StreamResponse(description: string): {
53
+ content: {
54
+ 'application/octet-stream': {
55
+ schema: z.ZodObject<{
56
+ body: z.ZodCustom<ReadableStream<any>, ReadableStream<any>>;
57
+ headers: z.ZodOptional<z.ZodObject<{
58
+ 'Content-Type': z.ZodDefault<z.ZodString>;
59
+ 'Content-Disposition': z.ZodString;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>;
62
+ };
63
+ };
64
+ description: string;
65
+ };
66
+ export declare function ApiPdfResponse(description: string): {
67
+ content: {
68
+ 'application/pdf': {
69
+ schema: z.ZodObject<{
70
+ format: z.ZodLiteral<"binary">;
71
+ type: z.ZodLiteral<"string">;
72
+ }, z.core.$strip>;
73
+ };
74
+ };
75
+ description: string;
76
+ };
@@ -0,0 +1,2 @@
1
+ export declare function throwHttpError(error: unknown, defaultMessage?: string): never;
2
+ export declare function isUniqueViolationPg(error: unknown): boolean;
@@ -0,0 +1,2 @@
1
+ import { ErrorHandler } from 'hono';
2
+ export declare function onErrorFn(debugLog?: boolean): ErrorHandler;
@@ -0,0 +1,2 @@
1
+ import { NotFoundHandler } from 'hono';
2
+ export declare const notFoundFn: NotFoundHandler;
@@ -0,0 +1,2 @@
1
+ import { ResponsePagination } from './api-response.util';
2
+ export declare function buildPaginationResponse(page: number | undefined, size: number | undefined, total: number): ResponsePagination;
@@ -0,0 +1,11 @@
1
+ import type { SignatureAlgorithm } from 'hono/utils/jwt/jwa';
2
+ import type { JWTPayload } from 'hono/utils/jwt/types';
3
+ export declare class TokenUtil {
4
+ private alg;
5
+ private secret;
6
+ constructor(secret: string, alg?: SignatureAlgorithm);
7
+ create<T extends JWTPayload>(payload: T, lifeSeconds?: number): Promise<string>;
8
+ decode<T extends JWTPayload>(token: string): Promise<T | null>;
9
+ decodeUnexpired<T extends JWTPayload>(token: string): Promise<T | null>;
10
+ expiresWithin(exp: number, seconds: number): boolean;
11
+ }
@@ -0,0 +1,2 @@
1
+ import { Context } from 'hono';
2
+ export declare function validationHook(result: any, _c: Context): void;