@okay-e9g/hono-config 0.0.2 → 0.0.3
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/package.json
CHANGED
|
@@ -14,7 +14,11 @@ import { statusText } from '../schemas';
|
|
|
14
14
|
*/
|
|
15
15
|
export const notFound = <T extends Env>(): NotFoundHandler<T> => {
|
|
16
16
|
return (c) => {
|
|
17
|
-
const { response } = c.var as ResponseEnv['Variables']
|
|
17
|
+
const { response } = c.var as Partial<ResponseEnv['Variables']>;
|
|
18
|
+
|
|
19
|
+
if (!response) {
|
|
20
|
+
return c.text(statusText[404], 404);
|
|
21
|
+
}
|
|
18
22
|
|
|
19
23
|
if (response.type === 'api') {
|
|
20
24
|
return c.json(response.error(404), 404);
|
package/src/handlers/on-error.ts
CHANGED
|
@@ -16,7 +16,12 @@ import { type ClientErrorStatusCode, type ServerErrorStatusCode, type StatusCode
|
|
|
16
16
|
*/
|
|
17
17
|
export const onError = <T extends Env>(): ErrorHandler<T> => {
|
|
18
18
|
return (err, c) => {
|
|
19
|
-
const { response } = c.var as ResponseEnv['Variables']
|
|
19
|
+
const { response } = c.var as Partial<ResponseEnv['Variables']>;
|
|
20
|
+
|
|
21
|
+
if (!response) {
|
|
22
|
+
console.error(err);
|
|
23
|
+
return c.text(statusText[500], 500);
|
|
24
|
+
}
|
|
20
25
|
|
|
21
26
|
if (err instanceof z.ZodError) {
|
|
22
27
|
if (response.type === 'api') {
|