@okay-e9g/hono-config 0.0.1 → 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/README.md +3 -0
- package/package.json +1 -7
- package/src/handlers/not-found.ts +5 -1
- package/src/handlers/on-error.ts +6 -1
package/README.md
ADDED
package/package.json
CHANGED
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
"dependencies": {},
|
|
3
3
|
"description": "Shared Hono config for Okay Engineering",
|
|
4
4
|
"devDependencies": {
|
|
5
|
-
"@cloudflare/workers-types": "5.20260705.1",
|
|
6
5
|
"@hono/zod-openapi": "1.4.0",
|
|
7
|
-
"@okay-e9g/biome-config": "workspace:*",
|
|
8
|
-
"@okay-e9g/tsconfig": "workspace:*",
|
|
9
|
-
"@types/bun": "1.3.14",
|
|
10
|
-
"@types/node": "26.1.0",
|
|
11
6
|
"hono": "4.12.27",
|
|
12
7
|
"superjson": "2.2.6",
|
|
13
|
-
"typescript": "6.0.3",
|
|
14
8
|
"zod": "4.4.3"
|
|
15
9
|
},
|
|
16
10
|
"exports": {
|
|
@@ -43,5 +37,5 @@
|
|
|
43
37
|
"prepublishOnly": "bun run typecheck && bun test",
|
|
44
38
|
"typecheck": "tsc --noEmit"
|
|
45
39
|
},
|
|
46
|
-
"version": "0.0.
|
|
40
|
+
"version": "0.0.3"
|
|
47
41
|
}
|
|
@@ -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') {
|