@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.
- package/README.md +386 -2
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +582 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +1 -0
- package/index.esm.js +552 -0
- package/package.json +33 -3
- package/src/index.d.ts +14 -0
- package/src/lib/constants/common.values.d.ts +2 -0
- package/src/lib/pino-logger/logger.helpers.d.ts +4 -0
- package/src/lib/pino-logger/pino-logger.d.ts +2 -0
- package/src/lib/pino-logger/pino-logger.middleware.d.ts +2 -0
- package/src/lib/predicates/is-prod.d.ts +5 -0
- package/src/lib/schemas/common.schema.d.ts +29 -0
- package/src/lib/services/crypto.service.d.ts +5 -0
- package/src/lib/utils/api-response.util.d.ts +76 -0
- package/src/lib/utils/error.util.d.ts +2 -0
- package/src/lib/utils/on-error.d.ts +2 -0
- package/src/lib/utils/on-not-found.d.ts +2 -0
- package/src/lib/utils/pagination.util.d.ts +2 -0
- package/src/lib/utils/token.util.d.ts +11 -0
- package/src/lib/utils/validation-hook.d.ts +2 -0
|
@@ -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,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
|
+
}
|