@navservice/core 1.92.0 → 1.95.0
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/build/es/helpers/_set_response.d.ts +86 -15
- package/build/es/helpers/_token.d.ts +2 -2
- package/build/es/helpers/index.d.ts +88 -17
- package/build/es/helpers.js +60 -71
- package/build/es/index.js +1 -1
- package/build/es/types/_type_response.d.ts +1 -1
- package/build/lib/helpers/_set_response.d.ts +86 -15
- package/build/lib/helpers/_token.d.ts +2 -2
- package/build/lib/helpers/index.d.ts +88 -17
- package/build/lib/helpers.cjs +28 -35
- package/build/lib/index.cjs +1 -1
- package/build/lib/types/_type_response.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,29 +6,41 @@ declare const set_response: {
|
|
|
6
6
|
new (): {};
|
|
7
7
|
c: {
|
|
8
8
|
new (): {};
|
|
9
|
-
SUCCESS<T>({ message, results, c }: ResponseCOmmit):
|
|
9
|
+
SUCCESS<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
10
10
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
11
11
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
12
12
|
type: "success" | "warning" | "error";
|
|
13
13
|
message?: string | undefined;
|
|
14
14
|
results: any;
|
|
15
|
-
}, 200, "json"
|
|
16
|
-
ACTION_REQUIRED<T>({ message, results, c }: ResponseCOmmit):
|
|
15
|
+
}, 200, "json">;
|
|
16
|
+
ACTION_REQUIRED<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
17
17
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
18
18
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
19
19
|
type: "success" | "warning" | "error";
|
|
20
20
|
message?: string | undefined;
|
|
21
21
|
results: any;
|
|
22
|
-
}, 428, "json"
|
|
23
|
-
CREATED<T>({ message, results, c }: ResponseCOmmit):
|
|
22
|
+
}, 428, "json">;
|
|
23
|
+
CREATED<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
24
24
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
25
25
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
26
26
|
type: "success" | "warning" | "error";
|
|
27
27
|
message?: string | undefined;
|
|
28
28
|
results: any;
|
|
29
|
-
}, 201, "json"
|
|
30
|
-
WARNING<T>({ message, results, c }: ResponseCOmmit):
|
|
31
|
-
|
|
29
|
+
}, 201, "json">;
|
|
30
|
+
WARNING<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
31
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
32
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
33
|
+
type: "success" | "warning" | "error";
|
|
34
|
+
message?: string | undefined;
|
|
35
|
+
results: any;
|
|
36
|
+
}, 400, "json">;
|
|
37
|
+
AUTHORIZATION_ERROR<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
38
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
39
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
40
|
+
type: "success" | "warning" | "error";
|
|
41
|
+
message?: string | undefined;
|
|
42
|
+
results: any;
|
|
43
|
+
}, 405, "json">;
|
|
32
44
|
SERVER_ERROR<T>({ error, c }: {
|
|
33
45
|
error: any;
|
|
34
46
|
c: t.Context;
|
|
@@ -39,28 +51,87 @@ declare const set_response: {
|
|
|
39
51
|
message?: string | undefined;
|
|
40
52
|
results: any;
|
|
41
53
|
}, any, "json">;
|
|
42
|
-
UNAUTHORIZED<T>({ message, c }: ResponseCOmmit):
|
|
54
|
+
UNAUTHORIZED<T>({ message, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
55
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
56
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
57
|
+
type: "success" | "warning" | "error";
|
|
58
|
+
message?: string | undefined;
|
|
59
|
+
results: any;
|
|
60
|
+
}, 401, "json">;
|
|
61
|
+
INVALID_TOKEN<T>({ message, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
43
62
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
44
63
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
45
64
|
type: "success" | "warning" | "error";
|
|
46
65
|
message?: string | undefined;
|
|
47
66
|
results: any;
|
|
48
|
-
},
|
|
49
|
-
|
|
67
|
+
}, 409, "json">;
|
|
68
|
+
NOT_FOUND<T>({ message, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
50
69
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
51
70
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
52
71
|
type: "success" | "warning" | "error";
|
|
53
72
|
message?: string | undefined;
|
|
54
73
|
results: any;
|
|
55
|
-
},
|
|
56
|
-
|
|
74
|
+
}, 404, "json">;
|
|
75
|
+
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: t.Geral.Response.C.FileResponseParams): Promise<(Response & import("hono").TypedResponse<{
|
|
76
|
+
readonly byteLength: number;
|
|
77
|
+
slice: never;
|
|
78
|
+
readonly maxByteLength: number;
|
|
79
|
+
readonly resizable: boolean;
|
|
80
|
+
resize: never;
|
|
81
|
+
readonly detached: boolean;
|
|
82
|
+
transfer: never;
|
|
83
|
+
transferToFixedLength: never;
|
|
84
|
+
} | {
|
|
85
|
+
readonly size: number;
|
|
86
|
+
readonly type: string;
|
|
87
|
+
slice: never;
|
|
88
|
+
} | {
|
|
89
|
+
[x: number]: number;
|
|
90
|
+
readonly BYTES_PER_ELEMENT: number;
|
|
91
|
+
readonly buffer: {
|
|
92
|
+
readonly byteLength: number;
|
|
93
|
+
slice: never;
|
|
94
|
+
readonly maxByteLength: number;
|
|
95
|
+
readonly resizable: boolean;
|
|
96
|
+
resize: never;
|
|
97
|
+
readonly detached: boolean;
|
|
98
|
+
transfer: never;
|
|
99
|
+
transferToFixedLength: never;
|
|
100
|
+
};
|
|
101
|
+
readonly byteLength: number;
|
|
102
|
+
readonly byteOffset: number;
|
|
103
|
+
copyWithin: never;
|
|
104
|
+
every: never;
|
|
105
|
+
fill: never;
|
|
106
|
+
filter: never;
|
|
107
|
+
find: never;
|
|
108
|
+
findIndex: never;
|
|
109
|
+
forEach: never;
|
|
110
|
+
indexOf: never;
|
|
111
|
+
join: never;
|
|
112
|
+
lastIndexOf: never;
|
|
113
|
+
readonly length: number;
|
|
114
|
+
map: never;
|
|
115
|
+
reduce: never;
|
|
116
|
+
reduceRight: never;
|
|
117
|
+
set: never;
|
|
118
|
+
slice: never;
|
|
119
|
+
some: never;
|
|
120
|
+
sort: never;
|
|
121
|
+
subarray: never;
|
|
122
|
+
includes: never;
|
|
123
|
+
at: never;
|
|
124
|
+
findLast: never;
|
|
125
|
+
findLastIndex: never;
|
|
126
|
+
toSorted: never;
|
|
127
|
+
with: never;
|
|
128
|
+
}, 200, "json">) | (Response & import("hono").TypedResponse<{
|
|
57
129
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
58
130
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
59
131
|
type: "success" | "warning" | "error";
|
|
60
132
|
message?: string | undefined;
|
|
61
133
|
results: any;
|
|
62
|
-
},
|
|
63
|
-
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: t.Geral.Response.C.FileResponseParams): Promise<Response | ResponseCPayload<unknown>>;
|
|
134
|
+
}, 200, "json">)>;
|
|
64
135
|
};
|
|
65
136
|
error: {
|
|
66
137
|
new (): {};
|
|
@@ -2,13 +2,13 @@ import type { Next } from 'hono';
|
|
|
2
2
|
import t from '../types';
|
|
3
3
|
declare const _token: {
|
|
4
4
|
new (): {};
|
|
5
|
-
verificar_token(c: t.Context, next: Next): Promise<void |
|
|
5
|
+
verificar_token(c: t.Context, next: Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
6
6
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
7
7
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
8
8
|
type: "success" | "warning" | "error";
|
|
9
9
|
message?: string | undefined;
|
|
10
10
|
results: any;
|
|
11
|
-
},
|
|
11
|
+
}, 409, "json">)>;
|
|
12
12
|
criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }: t.Controller.Usuario.TokenPayload & {
|
|
13
13
|
c: t.Context;
|
|
14
14
|
}): Promise<string>;
|
|
@@ -9,45 +9,57 @@ declare const helpers: {
|
|
|
9
9
|
message?: string | undefined;
|
|
10
10
|
results: any;
|
|
11
11
|
c: import("..").TypesCore.Context;
|
|
12
|
-
}):
|
|
12
|
+
}): Response & import("hono").TypedResponse<{
|
|
13
13
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
14
14
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
15
15
|
type: "success" | "warning" | "error";
|
|
16
16
|
message?: string | undefined;
|
|
17
17
|
results: any;
|
|
18
|
-
}, 200, "json"
|
|
18
|
+
}, 200, "json">;
|
|
19
19
|
ACTION_REQUIRED<T>({ message, results, c }: {
|
|
20
20
|
message?: string | undefined;
|
|
21
21
|
results: any;
|
|
22
22
|
c: import("..").TypesCore.Context;
|
|
23
|
-
}):
|
|
23
|
+
}): Response & import("hono").TypedResponse<{
|
|
24
24
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
25
25
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
26
26
|
type: "success" | "warning" | "error";
|
|
27
27
|
message?: string | undefined;
|
|
28
28
|
results: any;
|
|
29
|
-
}, 428, "json"
|
|
29
|
+
}, 428, "json">;
|
|
30
30
|
CREATED<T>({ message, results, c }: {
|
|
31
31
|
message?: string | undefined;
|
|
32
32
|
results: any;
|
|
33
33
|
c: import("..").TypesCore.Context;
|
|
34
|
-
}):
|
|
34
|
+
}): Response & import("hono").TypedResponse<{
|
|
35
35
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
36
36
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
37
37
|
type: "success" | "warning" | "error";
|
|
38
38
|
message?: string | undefined;
|
|
39
39
|
results: any;
|
|
40
|
-
}, 201, "json"
|
|
40
|
+
}, 201, "json">;
|
|
41
41
|
WARNING<T>({ message, results, c }: {
|
|
42
42
|
message?: string | undefined;
|
|
43
43
|
results: any;
|
|
44
44
|
c: import("..").TypesCore.Context;
|
|
45
|
-
}):
|
|
45
|
+
}): Response & import("hono").TypedResponse<{
|
|
46
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
47
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
48
|
+
type: "success" | "warning" | "error";
|
|
49
|
+
message?: string | undefined;
|
|
50
|
+
results: any;
|
|
51
|
+
}, 400, "json">;
|
|
46
52
|
AUTHORIZATION_ERROR<T>({ message, results, c }: {
|
|
47
53
|
message?: string | undefined;
|
|
48
54
|
results: any;
|
|
49
55
|
c: import("..").TypesCore.Context;
|
|
50
|
-
}):
|
|
56
|
+
}): Response & import("hono").TypedResponse<{
|
|
57
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
58
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
59
|
+
type: "success" | "warning" | "error";
|
|
60
|
+
message?: string | undefined;
|
|
61
|
+
results: any;
|
|
62
|
+
}, 405, "json">;
|
|
51
63
|
SERVER_ERROR<T>({ error, c }: {
|
|
52
64
|
error: any;
|
|
53
65
|
c: import("..").TypesCore.Context;
|
|
@@ -62,36 +74,95 @@ declare const helpers: {
|
|
|
62
74
|
message?: string | undefined;
|
|
63
75
|
results: any;
|
|
64
76
|
c: import("..").TypesCore.Context;
|
|
65
|
-
}):
|
|
77
|
+
}): Response & import("hono").TypedResponse<{
|
|
66
78
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
67
79
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
68
80
|
type: "success" | "warning" | "error";
|
|
69
81
|
message?: string | undefined;
|
|
70
82
|
results: any;
|
|
71
|
-
}, 401, "json"
|
|
83
|
+
}, 401, "json">;
|
|
72
84
|
INVALID_TOKEN<T>({ message, c }: {
|
|
73
85
|
message?: string | undefined;
|
|
74
86
|
results: any;
|
|
75
87
|
c: import("..").TypesCore.Context;
|
|
76
|
-
}):
|
|
88
|
+
}): Response & import("hono").TypedResponse<{
|
|
77
89
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
78
90
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
79
91
|
type: "success" | "warning" | "error";
|
|
80
92
|
message?: string | undefined;
|
|
81
93
|
results: any;
|
|
82
|
-
},
|
|
94
|
+
}, 409, "json">;
|
|
83
95
|
NOT_FOUND<T>({ message, c }: {
|
|
84
96
|
message?: string | undefined;
|
|
85
97
|
results: any;
|
|
86
98
|
c: import("..").TypesCore.Context;
|
|
87
|
-
}):
|
|
99
|
+
}): Response & import("hono").TypedResponse<{
|
|
100
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
101
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
102
|
+
type: "success" | "warning" | "error";
|
|
103
|
+
message?: string | undefined;
|
|
104
|
+
results: any;
|
|
105
|
+
}, 404, "json">;
|
|
106
|
+
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: import("../types/_type_response").default.C.FileResponseParams): Promise<(Response & import("hono").TypedResponse<{
|
|
107
|
+
readonly byteLength: number;
|
|
108
|
+
slice: never;
|
|
109
|
+
readonly maxByteLength: number;
|
|
110
|
+
readonly resizable: boolean;
|
|
111
|
+
resize: never;
|
|
112
|
+
readonly detached: boolean;
|
|
113
|
+
transfer: never;
|
|
114
|
+
transferToFixedLength: never;
|
|
115
|
+
} | {
|
|
116
|
+
readonly size: number;
|
|
117
|
+
readonly type: string;
|
|
118
|
+
slice: never;
|
|
119
|
+
} | {
|
|
120
|
+
[x: number]: number;
|
|
121
|
+
readonly BYTES_PER_ELEMENT: number;
|
|
122
|
+
readonly buffer: {
|
|
123
|
+
readonly byteLength: number;
|
|
124
|
+
slice: never;
|
|
125
|
+
readonly maxByteLength: number;
|
|
126
|
+
readonly resizable: boolean;
|
|
127
|
+
resize: never;
|
|
128
|
+
readonly detached: boolean;
|
|
129
|
+
transfer: never;
|
|
130
|
+
transferToFixedLength: never;
|
|
131
|
+
};
|
|
132
|
+
readonly byteLength: number;
|
|
133
|
+
readonly byteOffset: number;
|
|
134
|
+
copyWithin: never;
|
|
135
|
+
every: never;
|
|
136
|
+
fill: never;
|
|
137
|
+
filter: never;
|
|
138
|
+
find: never;
|
|
139
|
+
findIndex: never;
|
|
140
|
+
forEach: never;
|
|
141
|
+
indexOf: never;
|
|
142
|
+
join: never;
|
|
143
|
+
lastIndexOf: never;
|
|
144
|
+
readonly length: number;
|
|
145
|
+
map: never;
|
|
146
|
+
reduce: never;
|
|
147
|
+
reduceRight: never;
|
|
148
|
+
set: never;
|
|
149
|
+
slice: never;
|
|
150
|
+
some: never;
|
|
151
|
+
sort: never;
|
|
152
|
+
subarray: never;
|
|
153
|
+
includes: never;
|
|
154
|
+
at: never;
|
|
155
|
+
findLast: never;
|
|
156
|
+
findLastIndex: never;
|
|
157
|
+
toSorted: never;
|
|
158
|
+
with: never;
|
|
159
|
+
}, 200, "json">) | (Response & import("hono").TypedResponse<{
|
|
88
160
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
89
161
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
90
162
|
type: "success" | "warning" | "error";
|
|
91
163
|
message?: string | undefined;
|
|
92
164
|
results: any;
|
|
93
|
-
},
|
|
94
|
-
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: import("../types/_type_response").default.C.FileResponseParams): Promise<Response | import("./_set_response").ResponseCPayload<unknown>>;
|
|
165
|
+
}, 200, "json">)>;
|
|
95
166
|
};
|
|
96
167
|
error: {
|
|
97
168
|
new (): {};
|
|
@@ -133,13 +204,13 @@ declare const helpers: {
|
|
|
133
204
|
};
|
|
134
205
|
token: {
|
|
135
206
|
new (): {};
|
|
136
|
-
verificar_token(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void |
|
|
207
|
+
verificar_token(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
137
208
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
138
209
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
139
210
|
type: "success" | "warning" | "error";
|
|
140
211
|
message?: string | undefined;
|
|
141
212
|
results: any;
|
|
142
|
-
},
|
|
213
|
+
}, 409, "json">)>;
|
|
143
214
|
criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }: import("../types/_usuario").default.TokenPayload & {
|
|
144
215
|
c: import("..").TypesCore.Context;
|
|
145
216
|
}): Promise<string>;
|
package/build/es/helpers.js
CHANGED
|
@@ -12,10 +12,9 @@ const set_response = class {
|
|
|
12
12
|
message: message || "Realizado com sucesso!",
|
|
13
13
|
results: results || []
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
return c.json(payload, {
|
|
16
16
|
status: 200
|
|
17
17
|
});
|
|
18
|
-
return payload;
|
|
19
18
|
}
|
|
20
19
|
static ACTION_REQUIRED({ message, results, c }) {
|
|
21
20
|
const payload = {
|
|
@@ -25,10 +24,9 @@ const set_response = class {
|
|
|
25
24
|
message: message || "Ação adicional necessária!",
|
|
26
25
|
results: results || []
|
|
27
26
|
};
|
|
28
|
-
|
|
27
|
+
return c.json(payload, {
|
|
29
28
|
status: 428
|
|
30
29
|
});
|
|
31
|
-
return payload;
|
|
32
30
|
}
|
|
33
31
|
static CREATED({ message, results, c }) {
|
|
34
32
|
const payload = {
|
|
@@ -38,9 +36,9 @@ const set_response = class {
|
|
|
38
36
|
message: message || "Criado com sucesso!",
|
|
39
37
|
results: results || []
|
|
40
38
|
};
|
|
41
|
-
return c
|
|
39
|
+
return c.json(payload, {
|
|
42
40
|
status: 201
|
|
43
|
-
})
|
|
41
|
+
});
|
|
44
42
|
}
|
|
45
43
|
static WARNING({ message, results, c }) {
|
|
46
44
|
const payload = {
|
|
@@ -50,10 +48,9 @@ const set_response = class {
|
|
|
50
48
|
message: message || "Aviso!",
|
|
51
49
|
results: results || []
|
|
52
50
|
};
|
|
53
|
-
|
|
51
|
+
return c.json(payload, {
|
|
54
52
|
status: 400
|
|
55
53
|
});
|
|
56
|
-
throw payload;
|
|
57
54
|
}
|
|
58
55
|
static AUTHORIZATION_ERROR({ message, results, c }) {
|
|
59
56
|
const payload = {
|
|
@@ -63,10 +60,9 @@ const set_response = class {
|
|
|
63
60
|
message: message || "Aviso!",
|
|
64
61
|
results: results || []
|
|
65
62
|
};
|
|
66
|
-
|
|
63
|
+
return c.json(payload, {
|
|
67
64
|
status: 405
|
|
68
65
|
});
|
|
69
|
-
throw payload;
|
|
70
66
|
}
|
|
71
67
|
static SERVER_ERROR({ error, c }) {
|
|
72
68
|
if (error instanceof v4.ZodError) {
|
|
@@ -100,21 +96,21 @@ const set_response = class {
|
|
|
100
96
|
message: message || "Não autorizado!",
|
|
101
97
|
results: []
|
|
102
98
|
};
|
|
103
|
-
return c
|
|
99
|
+
return c.json(payload, {
|
|
104
100
|
status: 401
|
|
105
|
-
})
|
|
101
|
+
});
|
|
106
102
|
}
|
|
107
103
|
static INVALID_TOKEN({ message, c }) {
|
|
108
104
|
const payload = {
|
|
109
|
-
status:
|
|
105
|
+
status: 409,
|
|
110
106
|
code: "INVALID_TOKEN",
|
|
111
107
|
type: "warning",
|
|
112
108
|
message: message || "Token inválido!",
|
|
113
109
|
results: []
|
|
114
110
|
};
|
|
115
|
-
return c
|
|
116
|
-
status:
|
|
117
|
-
})
|
|
111
|
+
return c.json(payload, {
|
|
112
|
+
status: 409
|
|
113
|
+
});
|
|
118
114
|
}
|
|
119
115
|
static NOT_FOUND({ message, c }) {
|
|
120
116
|
const payload = {
|
|
@@ -124,9 +120,9 @@ const set_response = class {
|
|
|
124
120
|
message: message || "Recurso não encontrado!",
|
|
125
121
|
results: []
|
|
126
122
|
};
|
|
127
|
-
return c
|
|
123
|
+
return c.json(payload, {
|
|
128
124
|
status: 404
|
|
129
|
-
})
|
|
125
|
+
});
|
|
130
126
|
}
|
|
131
127
|
static async SUCCESS_FILE({ message, file_buffer, content_type, filename, c }) {
|
|
132
128
|
if (c && content_type) {
|
|
@@ -134,7 +130,7 @@ const set_response = class {
|
|
|
134
130
|
"Content-Type": content_type,
|
|
135
131
|
"Content-Disposition": filename ? `inline; filename="${filename}"` : "inline"
|
|
136
132
|
};
|
|
137
|
-
return
|
|
133
|
+
return c.json(file_buffer, {
|
|
138
134
|
status: 200,
|
|
139
135
|
headers
|
|
140
136
|
});
|
|
@@ -146,9 +142,9 @@ const set_response = class {
|
|
|
146
142
|
message: message || "Erro ao retornar arquivo!",
|
|
147
143
|
results: []
|
|
148
144
|
};
|
|
149
|
-
return c
|
|
145
|
+
return c.json(payload, {
|
|
150
146
|
status: 200
|
|
151
|
-
})
|
|
147
|
+
});
|
|
152
148
|
}
|
|
153
149
|
};
|
|
154
150
|
static error = class {
|
|
@@ -268,65 +264,24 @@ const set_response = class {
|
|
|
268
264
|
};
|
|
269
265
|
};
|
|
270
266
|
const _set_response = set_response;
|
|
271
|
-
const scryptAsync = promisify(scrypt);
|
|
272
|
-
class _secret {
|
|
273
|
-
static SALT_LENGTH = 22;
|
|
274
|
-
static KEY_LENGTH = 35;
|
|
275
|
-
static async gerar_hash_senha(password) {
|
|
276
|
-
const salt = randomBytes(this.SALT_LENGTH);
|
|
277
|
-
const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
|
|
278
|
-
return salt.toString('base64') + '.' + derivedKey.toString('base64');
|
|
279
|
-
}
|
|
280
|
-
static async verify({ password, dashed_senha }) {
|
|
281
|
-
try {
|
|
282
|
-
const [saltBase64, hashBase64] = dashed_senha.split('.');
|
|
283
|
-
if (!saltBase64 || !hashBase64) return false;
|
|
284
|
-
const salt = Buffer.from(saltBase64, 'base64');
|
|
285
|
-
const storedHash = Buffer.from(hashBase64, 'base64');
|
|
286
|
-
const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
|
|
287
|
-
return timingSafeEqual(storedHash, derivedKey);
|
|
288
|
-
} catch {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
const helpers_secret = _secret;
|
|
294
|
-
class _data {
|
|
295
|
-
static get get_now_format_number() {
|
|
296
|
-
return Math.floor(Date.now() / 1000);
|
|
297
|
-
}
|
|
298
|
-
static verificar_data(value) {
|
|
299
|
-
const data = new Date(1000 * value);
|
|
300
|
-
if (isNaN(data.getTime())) throw new Error("Timestamp está inválido.");
|
|
301
|
-
return value;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
const helpers_data = _data;
|
|
305
|
-
const helpers = {
|
|
306
|
-
set_response: _set_response,
|
|
307
|
-
token: helpers_token,
|
|
308
|
-
secret: helpers_secret,
|
|
309
|
-
data: helpers_data
|
|
310
|
-
};
|
|
311
|
-
const src_helpers = helpers;
|
|
312
267
|
const _token = class {
|
|
313
268
|
static async verificar_token(c, next) {
|
|
314
269
|
try {
|
|
315
270
|
const authHeader = c.req.header("Authorization");
|
|
316
|
-
if (!authHeader) return
|
|
271
|
+
if (!authHeader) return _set_response.c.INVALID_TOKEN({
|
|
317
272
|
message: 'token não enviado!!!',
|
|
318
273
|
c: c,
|
|
319
274
|
results: []
|
|
320
275
|
});
|
|
321
276
|
const token = authHeader.split(" ")[1];
|
|
322
|
-
if (!token) return
|
|
277
|
+
if (!token) return _set_response.c.INVALID_TOKEN({
|
|
323
278
|
message: 'Acesso negado!!!',
|
|
324
279
|
c: c,
|
|
325
280
|
results: []
|
|
326
281
|
});
|
|
327
282
|
const secret = new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER);
|
|
328
283
|
const { payload } = await jwtVerify(token, secret);
|
|
329
|
-
if (!payload._id || !payload.email) return
|
|
284
|
+
if (!payload._id || !payload.email) return _set_response.c.INVALID_TOKEN({
|
|
330
285
|
message: 'Token inválido!!!!',
|
|
331
286
|
c: c,
|
|
332
287
|
results: []
|
|
@@ -343,7 +298,7 @@ const _token = class {
|
|
|
343
298
|
c.set("usuario_auth", setar_token);
|
|
344
299
|
return await next();
|
|
345
300
|
} catch (error) {
|
|
346
|
-
return
|
|
301
|
+
return _set_response.c.INVALID_TOKEN({
|
|
347
302
|
message: 'Token inválido!!!',
|
|
348
303
|
c: c,
|
|
349
304
|
results: []
|
|
@@ -351,7 +306,7 @@ const _token = class {
|
|
|
351
306
|
}
|
|
352
307
|
}
|
|
353
308
|
static async criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }) {
|
|
354
|
-
if (!c.env.JSON_WEB_TOKEN_AUTH_USER) return
|
|
309
|
+
if (!c.env.JSON_WEB_TOKEN_AUTH_USER) return _set_response.error.WARNING({
|
|
355
310
|
message: "Erro ao gerar token!!",
|
|
356
311
|
results: []
|
|
357
312
|
});
|
|
@@ -365,7 +320,7 @@ const _token = class {
|
|
|
365
320
|
nome: nome
|
|
366
321
|
}).setProtectedHeader({
|
|
367
322
|
alg: "HS256"
|
|
368
|
-
}).setIssuedAt().sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>
|
|
323
|
+
}).setIssuedAt().sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>_set_response.error.WARNING({
|
|
369
324
|
message: "Erro ao gerar token!",
|
|
370
325
|
results: error?.message
|
|
371
326
|
}));
|
|
@@ -373,11 +328,45 @@ const _token = class {
|
|
|
373
328
|
}
|
|
374
329
|
};
|
|
375
330
|
const helpers_token = _token;
|
|
376
|
-
const
|
|
331
|
+
const scryptAsync = promisify(scrypt);
|
|
332
|
+
class _secret {
|
|
333
|
+
static SALT_LENGTH = 22;
|
|
334
|
+
static KEY_LENGTH = 35;
|
|
335
|
+
static async gerar_hash_senha(password) {
|
|
336
|
+
const salt = randomBytes(this.SALT_LENGTH);
|
|
337
|
+
const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
|
|
338
|
+
return salt.toString('base64') + '.' + derivedKey.toString('base64');
|
|
339
|
+
}
|
|
340
|
+
static async verify({ password, dashed_senha }) {
|
|
341
|
+
try {
|
|
342
|
+
const [saltBase64, hashBase64] = dashed_senha.split('.');
|
|
343
|
+
if (!saltBase64 || !hashBase64) return false;
|
|
344
|
+
const salt = Buffer.from(saltBase64, 'base64');
|
|
345
|
+
const storedHash = Buffer.from(hashBase64, 'base64');
|
|
346
|
+
const derivedKey = await scryptAsync(password, salt, this.KEY_LENGTH);
|
|
347
|
+
return timingSafeEqual(storedHash, derivedKey);
|
|
348
|
+
} catch {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
const helpers_secret = _secret;
|
|
354
|
+
class _data {
|
|
355
|
+
static get get_now_format_number() {
|
|
356
|
+
return Math.floor(Date.now() / 1000);
|
|
357
|
+
}
|
|
358
|
+
static verificar_data(value) {
|
|
359
|
+
const data = new Date(1000 * value);
|
|
360
|
+
if (isNaN(data.getTime())) throw new Error("Timestamp está inválido.");
|
|
361
|
+
return value;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const helpers_data = _data;
|
|
365
|
+
const helpers = {
|
|
377
366
|
set_response: _set_response,
|
|
378
367
|
token: helpers_token,
|
|
379
368
|
secret: helpers_secret,
|
|
380
369
|
data: helpers_data
|
|
381
370
|
};
|
|
382
|
-
const
|
|
383
|
-
export {
|
|
371
|
+
const src_helpers = helpers;
|
|
372
|
+
export { src_helpers as default };
|
package/build/es/index.js
CHANGED
|
@@ -31,7 +31,7 @@ declare namespace TypeControllerResponse {
|
|
|
31
31
|
file_buffer: z4.ZodUnion<readonly [z4.ZodCustom<Blob, Blob>, z4.ZodCustom<ArrayBuffer, ArrayBuffer>, z4.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>]>;
|
|
32
32
|
content_type: z4.ZodString;
|
|
33
33
|
filename: z4.ZodOptional<z4.ZodString>;
|
|
34
|
-
c: z4.
|
|
34
|
+
c: z4.ZodCustom<t.Context, t.Context>;
|
|
35
35
|
}, z4.core.$strip>;
|
|
36
36
|
export type FileResponseParams = z4.infer<typeof FileResponseParamsSchema>;
|
|
37
37
|
export {};
|
|
@@ -6,29 +6,41 @@ declare const set_response: {
|
|
|
6
6
|
new (): {};
|
|
7
7
|
c: {
|
|
8
8
|
new (): {};
|
|
9
|
-
SUCCESS<T>({ message, results, c }: ResponseCOmmit):
|
|
9
|
+
SUCCESS<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
10
10
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
11
11
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
12
12
|
type: "success" | "warning" | "error";
|
|
13
13
|
message?: string | undefined;
|
|
14
14
|
results: any;
|
|
15
|
-
}, 200, "json"
|
|
16
|
-
ACTION_REQUIRED<T>({ message, results, c }: ResponseCOmmit):
|
|
15
|
+
}, 200, "json">;
|
|
16
|
+
ACTION_REQUIRED<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
17
17
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
18
18
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
19
19
|
type: "success" | "warning" | "error";
|
|
20
20
|
message?: string | undefined;
|
|
21
21
|
results: any;
|
|
22
|
-
}, 428, "json"
|
|
23
|
-
CREATED<T>({ message, results, c }: ResponseCOmmit):
|
|
22
|
+
}, 428, "json">;
|
|
23
|
+
CREATED<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
24
24
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
25
25
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
26
26
|
type: "success" | "warning" | "error";
|
|
27
27
|
message?: string | undefined;
|
|
28
28
|
results: any;
|
|
29
|
-
}, 201, "json"
|
|
30
|
-
WARNING<T>({ message, results, c }: ResponseCOmmit):
|
|
31
|
-
|
|
29
|
+
}, 201, "json">;
|
|
30
|
+
WARNING<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
31
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
32
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
33
|
+
type: "success" | "warning" | "error";
|
|
34
|
+
message?: string | undefined;
|
|
35
|
+
results: any;
|
|
36
|
+
}, 400, "json">;
|
|
37
|
+
AUTHORIZATION_ERROR<T>({ message, results, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
38
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
39
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
40
|
+
type: "success" | "warning" | "error";
|
|
41
|
+
message?: string | undefined;
|
|
42
|
+
results: any;
|
|
43
|
+
}, 405, "json">;
|
|
32
44
|
SERVER_ERROR<T>({ error, c }: {
|
|
33
45
|
error: any;
|
|
34
46
|
c: t.Context;
|
|
@@ -39,28 +51,87 @@ declare const set_response: {
|
|
|
39
51
|
message?: string | undefined;
|
|
40
52
|
results: any;
|
|
41
53
|
}, any, "json">;
|
|
42
|
-
UNAUTHORIZED<T>({ message, c }: ResponseCOmmit):
|
|
54
|
+
UNAUTHORIZED<T>({ message, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
55
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
56
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
57
|
+
type: "success" | "warning" | "error";
|
|
58
|
+
message?: string | undefined;
|
|
59
|
+
results: any;
|
|
60
|
+
}, 401, "json">;
|
|
61
|
+
INVALID_TOKEN<T>({ message, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
43
62
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
44
63
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
45
64
|
type: "success" | "warning" | "error";
|
|
46
65
|
message?: string | undefined;
|
|
47
66
|
results: any;
|
|
48
|
-
},
|
|
49
|
-
|
|
67
|
+
}, 409, "json">;
|
|
68
|
+
NOT_FOUND<T>({ message, c }: ResponseCOmmit): Response & import("hono").TypedResponse<{
|
|
50
69
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
51
70
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
52
71
|
type: "success" | "warning" | "error";
|
|
53
72
|
message?: string | undefined;
|
|
54
73
|
results: any;
|
|
55
|
-
},
|
|
56
|
-
|
|
74
|
+
}, 404, "json">;
|
|
75
|
+
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: t.Geral.Response.C.FileResponseParams): Promise<(Response & import("hono").TypedResponse<{
|
|
76
|
+
readonly byteLength: number;
|
|
77
|
+
slice: never;
|
|
78
|
+
readonly maxByteLength: number;
|
|
79
|
+
readonly resizable: boolean;
|
|
80
|
+
resize: never;
|
|
81
|
+
readonly detached: boolean;
|
|
82
|
+
transfer: never;
|
|
83
|
+
transferToFixedLength: never;
|
|
84
|
+
} | {
|
|
85
|
+
readonly size: number;
|
|
86
|
+
readonly type: string;
|
|
87
|
+
slice: never;
|
|
88
|
+
} | {
|
|
89
|
+
[x: number]: number;
|
|
90
|
+
readonly BYTES_PER_ELEMENT: number;
|
|
91
|
+
readonly buffer: {
|
|
92
|
+
readonly byteLength: number;
|
|
93
|
+
slice: never;
|
|
94
|
+
readonly maxByteLength: number;
|
|
95
|
+
readonly resizable: boolean;
|
|
96
|
+
resize: never;
|
|
97
|
+
readonly detached: boolean;
|
|
98
|
+
transfer: never;
|
|
99
|
+
transferToFixedLength: never;
|
|
100
|
+
};
|
|
101
|
+
readonly byteLength: number;
|
|
102
|
+
readonly byteOffset: number;
|
|
103
|
+
copyWithin: never;
|
|
104
|
+
every: never;
|
|
105
|
+
fill: never;
|
|
106
|
+
filter: never;
|
|
107
|
+
find: never;
|
|
108
|
+
findIndex: never;
|
|
109
|
+
forEach: never;
|
|
110
|
+
indexOf: never;
|
|
111
|
+
join: never;
|
|
112
|
+
lastIndexOf: never;
|
|
113
|
+
readonly length: number;
|
|
114
|
+
map: never;
|
|
115
|
+
reduce: never;
|
|
116
|
+
reduceRight: never;
|
|
117
|
+
set: never;
|
|
118
|
+
slice: never;
|
|
119
|
+
some: never;
|
|
120
|
+
sort: never;
|
|
121
|
+
subarray: never;
|
|
122
|
+
includes: never;
|
|
123
|
+
at: never;
|
|
124
|
+
findLast: never;
|
|
125
|
+
findLastIndex: never;
|
|
126
|
+
toSorted: never;
|
|
127
|
+
with: never;
|
|
128
|
+
}, 200, "json">) | (Response & import("hono").TypedResponse<{
|
|
57
129
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
58
130
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
59
131
|
type: "success" | "warning" | "error";
|
|
60
132
|
message?: string | undefined;
|
|
61
133
|
results: any;
|
|
62
|
-
},
|
|
63
|
-
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: t.Geral.Response.C.FileResponseParams): Promise<Response | ResponseCPayload<unknown>>;
|
|
134
|
+
}, 200, "json">)>;
|
|
64
135
|
};
|
|
65
136
|
error: {
|
|
66
137
|
new (): {};
|
|
@@ -2,13 +2,13 @@ import type { Next } from 'hono';
|
|
|
2
2
|
import t from '../types';
|
|
3
3
|
declare const _token: {
|
|
4
4
|
new (): {};
|
|
5
|
-
verificar_token(c: t.Context, next: Next): Promise<void |
|
|
5
|
+
verificar_token(c: t.Context, next: Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
6
6
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
7
7
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
8
8
|
type: "success" | "warning" | "error";
|
|
9
9
|
message?: string | undefined;
|
|
10
10
|
results: any;
|
|
11
|
-
},
|
|
11
|
+
}, 409, "json">)>;
|
|
12
12
|
criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }: t.Controller.Usuario.TokenPayload & {
|
|
13
13
|
c: t.Context;
|
|
14
14
|
}): Promise<string>;
|
|
@@ -9,45 +9,57 @@ declare const helpers: {
|
|
|
9
9
|
message?: string | undefined;
|
|
10
10
|
results: any;
|
|
11
11
|
c: import("..").TypesCore.Context;
|
|
12
|
-
}):
|
|
12
|
+
}): Response & import("hono").TypedResponse<{
|
|
13
13
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
14
14
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
15
15
|
type: "success" | "warning" | "error";
|
|
16
16
|
message?: string | undefined;
|
|
17
17
|
results: any;
|
|
18
|
-
}, 200, "json"
|
|
18
|
+
}, 200, "json">;
|
|
19
19
|
ACTION_REQUIRED<T>({ message, results, c }: {
|
|
20
20
|
message?: string | undefined;
|
|
21
21
|
results: any;
|
|
22
22
|
c: import("..").TypesCore.Context;
|
|
23
|
-
}):
|
|
23
|
+
}): Response & import("hono").TypedResponse<{
|
|
24
24
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
25
25
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
26
26
|
type: "success" | "warning" | "error";
|
|
27
27
|
message?: string | undefined;
|
|
28
28
|
results: any;
|
|
29
|
-
}, 428, "json"
|
|
29
|
+
}, 428, "json">;
|
|
30
30
|
CREATED<T>({ message, results, c }: {
|
|
31
31
|
message?: string | undefined;
|
|
32
32
|
results: any;
|
|
33
33
|
c: import("..").TypesCore.Context;
|
|
34
|
-
}):
|
|
34
|
+
}): Response & import("hono").TypedResponse<{
|
|
35
35
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
36
36
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
37
37
|
type: "success" | "warning" | "error";
|
|
38
38
|
message?: string | undefined;
|
|
39
39
|
results: any;
|
|
40
|
-
}, 201, "json"
|
|
40
|
+
}, 201, "json">;
|
|
41
41
|
WARNING<T>({ message, results, c }: {
|
|
42
42
|
message?: string | undefined;
|
|
43
43
|
results: any;
|
|
44
44
|
c: import("..").TypesCore.Context;
|
|
45
|
-
}):
|
|
45
|
+
}): Response & import("hono").TypedResponse<{
|
|
46
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
47
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
48
|
+
type: "success" | "warning" | "error";
|
|
49
|
+
message?: string | undefined;
|
|
50
|
+
results: any;
|
|
51
|
+
}, 400, "json">;
|
|
46
52
|
AUTHORIZATION_ERROR<T>({ message, results, c }: {
|
|
47
53
|
message?: string | undefined;
|
|
48
54
|
results: any;
|
|
49
55
|
c: import("..").TypesCore.Context;
|
|
50
|
-
}):
|
|
56
|
+
}): Response & import("hono").TypedResponse<{
|
|
57
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
58
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
59
|
+
type: "success" | "warning" | "error";
|
|
60
|
+
message?: string | undefined;
|
|
61
|
+
results: any;
|
|
62
|
+
}, 405, "json">;
|
|
51
63
|
SERVER_ERROR<T>({ error, c }: {
|
|
52
64
|
error: any;
|
|
53
65
|
c: import("..").TypesCore.Context;
|
|
@@ -62,36 +74,95 @@ declare const helpers: {
|
|
|
62
74
|
message?: string | undefined;
|
|
63
75
|
results: any;
|
|
64
76
|
c: import("..").TypesCore.Context;
|
|
65
|
-
}):
|
|
77
|
+
}): Response & import("hono").TypedResponse<{
|
|
66
78
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
67
79
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
68
80
|
type: "success" | "warning" | "error";
|
|
69
81
|
message?: string | undefined;
|
|
70
82
|
results: any;
|
|
71
|
-
}, 401, "json"
|
|
83
|
+
}, 401, "json">;
|
|
72
84
|
INVALID_TOKEN<T>({ message, c }: {
|
|
73
85
|
message?: string | undefined;
|
|
74
86
|
results: any;
|
|
75
87
|
c: import("..").TypesCore.Context;
|
|
76
|
-
}):
|
|
88
|
+
}): Response & import("hono").TypedResponse<{
|
|
77
89
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
78
90
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
79
91
|
type: "success" | "warning" | "error";
|
|
80
92
|
message?: string | undefined;
|
|
81
93
|
results: any;
|
|
82
|
-
},
|
|
94
|
+
}, 409, "json">;
|
|
83
95
|
NOT_FOUND<T>({ message, c }: {
|
|
84
96
|
message?: string | undefined;
|
|
85
97
|
results: any;
|
|
86
98
|
c: import("..").TypesCore.Context;
|
|
87
|
-
}):
|
|
99
|
+
}): Response & import("hono").TypedResponse<{
|
|
100
|
+
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
101
|
+
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
102
|
+
type: "success" | "warning" | "error";
|
|
103
|
+
message?: string | undefined;
|
|
104
|
+
results: any;
|
|
105
|
+
}, 404, "json">;
|
|
106
|
+
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: import("../types/_type_response").default.C.FileResponseParams): Promise<(Response & import("hono").TypedResponse<{
|
|
107
|
+
readonly byteLength: number;
|
|
108
|
+
slice: never;
|
|
109
|
+
readonly maxByteLength: number;
|
|
110
|
+
readonly resizable: boolean;
|
|
111
|
+
resize: never;
|
|
112
|
+
readonly detached: boolean;
|
|
113
|
+
transfer: never;
|
|
114
|
+
transferToFixedLength: never;
|
|
115
|
+
} | {
|
|
116
|
+
readonly size: number;
|
|
117
|
+
readonly type: string;
|
|
118
|
+
slice: never;
|
|
119
|
+
} | {
|
|
120
|
+
[x: number]: number;
|
|
121
|
+
readonly BYTES_PER_ELEMENT: number;
|
|
122
|
+
readonly buffer: {
|
|
123
|
+
readonly byteLength: number;
|
|
124
|
+
slice: never;
|
|
125
|
+
readonly maxByteLength: number;
|
|
126
|
+
readonly resizable: boolean;
|
|
127
|
+
resize: never;
|
|
128
|
+
readonly detached: boolean;
|
|
129
|
+
transfer: never;
|
|
130
|
+
transferToFixedLength: never;
|
|
131
|
+
};
|
|
132
|
+
readonly byteLength: number;
|
|
133
|
+
readonly byteOffset: number;
|
|
134
|
+
copyWithin: never;
|
|
135
|
+
every: never;
|
|
136
|
+
fill: never;
|
|
137
|
+
filter: never;
|
|
138
|
+
find: never;
|
|
139
|
+
findIndex: never;
|
|
140
|
+
forEach: never;
|
|
141
|
+
indexOf: never;
|
|
142
|
+
join: never;
|
|
143
|
+
lastIndexOf: never;
|
|
144
|
+
readonly length: number;
|
|
145
|
+
map: never;
|
|
146
|
+
reduce: never;
|
|
147
|
+
reduceRight: never;
|
|
148
|
+
set: never;
|
|
149
|
+
slice: never;
|
|
150
|
+
some: never;
|
|
151
|
+
sort: never;
|
|
152
|
+
subarray: never;
|
|
153
|
+
includes: never;
|
|
154
|
+
at: never;
|
|
155
|
+
findLast: never;
|
|
156
|
+
findLastIndex: never;
|
|
157
|
+
toSorted: never;
|
|
158
|
+
with: never;
|
|
159
|
+
}, 200, "json">) | (Response & import("hono").TypedResponse<{
|
|
88
160
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
89
161
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
90
162
|
type: "success" | "warning" | "error";
|
|
91
163
|
message?: string | undefined;
|
|
92
164
|
results: any;
|
|
93
|
-
},
|
|
94
|
-
SUCCESS_FILE({ message, file_buffer, content_type, filename, c }: import("../types/_type_response").default.C.FileResponseParams): Promise<Response | import("./_set_response").ResponseCPayload<unknown>>;
|
|
165
|
+
}, 200, "json">)>;
|
|
95
166
|
};
|
|
96
167
|
error: {
|
|
97
168
|
new (): {};
|
|
@@ -133,13 +204,13 @@ declare const helpers: {
|
|
|
133
204
|
};
|
|
134
205
|
token: {
|
|
135
206
|
new (): {};
|
|
136
|
-
verificar_token(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void |
|
|
207
|
+
verificar_token(c: import("..").TypesCore.Context, next: import("hono").Next): Promise<void | (Response & import("hono").TypedResponse<{
|
|
137
208
|
status: 200 | 201 | 202 | 204 | 400 | 401 | 403 | 404 | 409 | 422 | 500 | 428 | 405;
|
|
138
209
|
code: "SUCCESS" | "ACTION_REQUIRED" | "CREATED" | "WARNING" | "AUTHORIZATION_ERROR" | "SCHEMA_VALIDATION" | "SERVER_ERROR" | "UNAUTHORIZED" | "INVALID_TOKEN" | "NOT_FOUND" | "SUCCESS_FILE" | "DATABASE_ERROR";
|
|
139
210
|
type: "success" | "warning" | "error";
|
|
140
211
|
message?: string | undefined;
|
|
141
212
|
results: any;
|
|
142
|
-
},
|
|
213
|
+
}, 409, "json">)>;
|
|
143
214
|
criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }: import("../types/_usuario").default.TokenPayload & {
|
|
144
215
|
c: import("..").TypesCore.Context;
|
|
145
216
|
}): Promise<string>;
|
package/build/lib/helpers.cjs
CHANGED
|
@@ -70,12 +70,9 @@ const set_response = class set_response {
|
|
|
70
70
|
message: message || "Realizado com sucesso!",
|
|
71
71
|
results: results || []
|
|
72
72
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return payload;
|
|
73
|
+
return c.json(payload, {
|
|
74
|
+
status: 200
|
|
75
|
+
});
|
|
79
76
|
}
|
|
80
77
|
static ACTION_REQUIRED({ message, results, c }) {
|
|
81
78
|
const payload = {
|
|
@@ -85,12 +82,9 @@ const set_response = class set_response {
|
|
|
85
82
|
message: message || "Ação adicional necessária!",
|
|
86
83
|
results: results || []
|
|
87
84
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return payload;
|
|
85
|
+
return c.json(payload, {
|
|
86
|
+
status: 428
|
|
87
|
+
});
|
|
94
88
|
}
|
|
95
89
|
static CREATED({ message, results, c }) {
|
|
96
90
|
const payload = {
|
|
@@ -100,9 +94,9 @@ const set_response = class set_response {
|
|
|
100
94
|
message: message || "Criado com sucesso!",
|
|
101
95
|
results: results || []
|
|
102
96
|
};
|
|
103
|
-
return c
|
|
97
|
+
return c.json(payload, {
|
|
104
98
|
status: 201
|
|
105
|
-
})
|
|
99
|
+
});
|
|
106
100
|
}
|
|
107
101
|
static WARNING({ message, results, c }) {
|
|
108
102
|
const payload = {
|
|
@@ -112,10 +106,9 @@ const set_response = class set_response {
|
|
|
112
106
|
message: message || "Aviso!",
|
|
113
107
|
results: results || []
|
|
114
108
|
};
|
|
115
|
-
|
|
109
|
+
return c.json(payload, {
|
|
116
110
|
status: 400
|
|
117
111
|
});
|
|
118
|
-
throw payload;
|
|
119
112
|
}
|
|
120
113
|
static AUTHORIZATION_ERROR({ message, results, c }) {
|
|
121
114
|
const payload = {
|
|
@@ -125,10 +118,9 @@ const set_response = class set_response {
|
|
|
125
118
|
message: message || "Aviso!",
|
|
126
119
|
results: results || []
|
|
127
120
|
};
|
|
128
|
-
|
|
121
|
+
return c.json(payload, {
|
|
129
122
|
status: 405
|
|
130
123
|
});
|
|
131
|
-
throw payload;
|
|
132
124
|
}
|
|
133
125
|
static SERVER_ERROR({ error, c }) {
|
|
134
126
|
if (error instanceof (v4_default()).ZodError) {
|
|
@@ -162,21 +154,21 @@ const set_response = class set_response {
|
|
|
162
154
|
message: message || "Não autorizado!",
|
|
163
155
|
results: []
|
|
164
156
|
};
|
|
165
|
-
return c
|
|
157
|
+
return c.json(payload, {
|
|
166
158
|
status: 401
|
|
167
|
-
})
|
|
159
|
+
});
|
|
168
160
|
}
|
|
169
161
|
static INVALID_TOKEN({ message, c }) {
|
|
170
162
|
const payload = {
|
|
171
|
-
status:
|
|
163
|
+
status: 409,
|
|
172
164
|
code: "INVALID_TOKEN",
|
|
173
165
|
type: "warning",
|
|
174
166
|
message: message || "Token inválido!",
|
|
175
167
|
results: []
|
|
176
168
|
};
|
|
177
|
-
return c
|
|
178
|
-
status:
|
|
179
|
-
})
|
|
169
|
+
return c.json(payload, {
|
|
170
|
+
status: 409
|
|
171
|
+
});
|
|
180
172
|
}
|
|
181
173
|
static NOT_FOUND({ message, c }) {
|
|
182
174
|
const payload = {
|
|
@@ -186,9 +178,9 @@ const set_response = class set_response {
|
|
|
186
178
|
message: message || "Recurso não encontrado!",
|
|
187
179
|
results: []
|
|
188
180
|
};
|
|
189
|
-
return c
|
|
181
|
+
return c.json(payload, {
|
|
190
182
|
status: 404
|
|
191
|
-
})
|
|
183
|
+
});
|
|
192
184
|
}
|
|
193
185
|
static async SUCCESS_FILE({ message, file_buffer, content_type, filename, c }) {
|
|
194
186
|
if (c && content_type) {
|
|
@@ -196,7 +188,7 @@ const set_response = class set_response {
|
|
|
196
188
|
"Content-Type": content_type,
|
|
197
189
|
"Content-Disposition": filename ? `inline; filename="${filename}"` : "inline"
|
|
198
190
|
};
|
|
199
|
-
return
|
|
191
|
+
return c.json(file_buffer, {
|
|
200
192
|
status: 200,
|
|
201
193
|
headers
|
|
202
194
|
});
|
|
@@ -208,9 +200,9 @@ const set_response = class set_response {
|
|
|
208
200
|
message: message || "Erro ao retornar arquivo!",
|
|
209
201
|
results: []
|
|
210
202
|
};
|
|
211
|
-
return c
|
|
203
|
+
return c.json(payload, {
|
|
212
204
|
status: 200
|
|
213
|
-
})
|
|
205
|
+
});
|
|
214
206
|
}
|
|
215
207
|
};
|
|
216
208
|
static error = class error {
|
|
@@ -335,18 +327,19 @@ const set_response = class set_response {
|
|
|
335
327
|
const external_jose_namespaceObject = require("jose");
|
|
336
328
|
;// CONCATENATED MODULE: ./src/helpers/_token.ts
|
|
337
329
|
|
|
330
|
+
// Tem que importar assim para evitar dependencia circular
|
|
338
331
|
|
|
339
332
|
const _token = class _token {
|
|
340
333
|
static async verificar_token(c, next) {
|
|
341
334
|
try {
|
|
342
335
|
const authHeader = c.req.header("Authorization");
|
|
343
|
-
if (!authHeader) return
|
|
336
|
+
if (!authHeader) return _set_response.c.INVALID_TOKEN({
|
|
344
337
|
message: 'token não enviado!!!',
|
|
345
338
|
c: c,
|
|
346
339
|
results: []
|
|
347
340
|
});
|
|
348
341
|
const token = authHeader.split(" ")[1];
|
|
349
|
-
if (!token) return
|
|
342
|
+
if (!token) return _set_response.c.INVALID_TOKEN({
|
|
350
343
|
message: 'Acesso negado!!!',
|
|
351
344
|
c: c,
|
|
352
345
|
results: []
|
|
@@ -354,7 +347,7 @@ const _token = class _token {
|
|
|
354
347
|
const secret = new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER);
|
|
355
348
|
const { payload } = await external_jose_namespaceObject.jwtVerify(token, secret);
|
|
356
349
|
if (!payload._id || !payload.email) {
|
|
357
|
-
return
|
|
350
|
+
return _set_response.c.INVALID_TOKEN({
|
|
358
351
|
message: 'Token inválido!!!!',
|
|
359
352
|
c: c,
|
|
360
353
|
results: []
|
|
@@ -372,7 +365,7 @@ const _token = class _token {
|
|
|
372
365
|
c.set("usuario_auth", setar_token);
|
|
373
366
|
return await next();
|
|
374
367
|
} catch (error) {
|
|
375
|
-
return
|
|
368
|
+
return _set_response.c.INVALID_TOKEN({
|
|
376
369
|
message: 'Token inválido!!!',
|
|
377
370
|
c: c,
|
|
378
371
|
results: []
|
|
@@ -381,7 +374,7 @@ const _token = class _token {
|
|
|
381
374
|
}
|
|
382
375
|
static async criar_token_login_usuario({ _id, email, app, usuario_tipo, ativo, data_criacao, nome, c }) {
|
|
383
376
|
if (!c.env.JSON_WEB_TOKEN_AUTH_USER) {
|
|
384
|
-
return
|
|
377
|
+
return _set_response.error.WARNING({
|
|
385
378
|
message: "Erro ao gerar token!!",
|
|
386
379
|
results: []
|
|
387
380
|
});
|
|
@@ -398,7 +391,7 @@ const _token = class _token {
|
|
|
398
391
|
alg: "HS256"
|
|
399
392
|
}).setIssuedAt()//.setExpirationTime("24h")
|
|
400
393
|
.sign(new TextEncoder().encode(c.env.JSON_WEB_TOKEN_AUTH_USER)).catch((error)=>{
|
|
401
|
-
return
|
|
394
|
+
return _set_response.error.WARNING({
|
|
402
395
|
message: "Erro ao gerar token!",
|
|
403
396
|
results: error?.message
|
|
404
397
|
});
|
package/build/lib/index.cjs
CHANGED
|
@@ -143,7 +143,7 @@ var _usuario_TypeControllerUsuario;
|
|
|
143
143
|
]),
|
|
144
144
|
content_type: v4_default().string(),
|
|
145
145
|
filename: v4_default().string().optional(),
|
|
146
|
-
c: v4_default().custom()
|
|
146
|
+
c: v4_default().custom()
|
|
147
147
|
});
|
|
148
148
|
})(TypeControllerResponse.C || (TypeControllerResponse.C = {}));
|
|
149
149
|
(function(Error) {
|
|
@@ -31,7 +31,7 @@ declare namespace TypeControllerResponse {
|
|
|
31
31
|
file_buffer: z4.ZodUnion<readonly [z4.ZodCustom<Blob, Blob>, z4.ZodCustom<ArrayBuffer, ArrayBuffer>, z4.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>]>;
|
|
32
32
|
content_type: z4.ZodString;
|
|
33
33
|
filename: z4.ZodOptional<z4.ZodString>;
|
|
34
|
-
c: z4.
|
|
34
|
+
c: z4.ZodCustom<t.Context, t.Context>;
|
|
35
35
|
}, z4.core.$strip>;
|
|
36
36
|
export type FileResponseParams = z4.infer<typeof FileResponseParamsSchema>;
|
|
37
37
|
export {};
|