@web-ts-toolkit/express-json-router 0.3.0 → 0.5.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.
Files changed (2) hide show
  1. package/README.md +22 -14
  2. package/package.json +12 -9
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # @web-ts-toolkit/express-json-router
1
+ # `@web-ts-toolkit/express-json-router`
2
2
 
3
- Express router wrapper that wires route handlers through `@web-ts-toolkit/express-response-handler` and keeps track of registered endpoints.
3
+ Express router wrapper that routes handler return values through `@web-ts-toolkit/express-response-handler`.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,12 +8,14 @@ Express router wrapper that wires route handlers through `@web-ts-toolkit/expres
8
8
  pnpm add @web-ts-toolkit/express-json-router express
9
9
  ```
10
10
 
11
- ## Documentation
11
+ ## Highlights
12
12
 
13
- - Full package documentation lives in `website/docs/packages/express-json-router.md`.
14
- - Use the Docusaurus site in `website` for the complete guide and API notes.
13
+ - return plain values from route handlers
14
+ - throw typed HTTP errors
15
+ - use custom response-handler instances when needed
16
+ - inspect registered endpoints with `getEndpoints()`
15
17
 
16
- ## Minimal Example
18
+ ## Quick Start
17
19
 
18
20
  ```ts
19
21
  import express from 'express';
@@ -28,13 +30,19 @@ router.get('/users/:id', () => {
28
30
  throw new JsonRouter.clientErrors.NotFoundError('User not found');
29
31
  });
30
32
 
31
- JsonRouter.errorMessageProvider = (error) => {
32
- if (error instanceof Error) {
33
- return { message: error.message };
34
- }
35
-
36
- return { message: String(error) };
37
- };
38
-
39
33
  app.use(router.original);
40
34
  ```
35
+
36
+ ## Main Exports
37
+
38
+ - `JsonRouter`
39
+ - `JsonRouter.HttpResponse`
40
+ - `JsonRouter.clientErrors`
41
+ - `JsonRouter.createHandler(...)`
42
+ - `JsonRouter.ErrorFormats`
43
+
44
+ ## Documentation
45
+
46
+ Full package documentation lives in `website/docs/packages/express-json-router.md`.
47
+
48
+ - live docs: https://web-ts-toolkit.pages.dev/docs/packages/express-json-router
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@web-ts-toolkit/express-json-router",
3
- "description": "Express router wrapper for JSON responses",
4
- "version": "0.3.0",
3
+ "description": "Express router wrapper for return-value JSON responses",
4
+ "homepage": "https://web-ts-toolkit.pages.dev/docs/packages/express-json-router",
5
+ "version": "0.5.0",
6
+ "sideEffects": false,
5
7
  "keywords": [
6
8
  "express",
7
9
  "api",
8
10
  "json",
9
- "router"
11
+ "router",
12
+ "http"
10
13
  ],
11
14
  "main": "./index.js",
12
15
  "module": "./index.mjs",
@@ -19,19 +22,19 @@
19
22
  "default": "./index.js"
20
23
  }
21
24
  },
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
22
28
  "dependencies": {
23
- "@web-ts-toolkit/express-response-handler": "0.3.0",
24
- "@web-ts-toolkit/http-errors": "0.3.0",
25
- "@web-ts-toolkit/utils": "0.3.0",
29
+ "@web-ts-toolkit/express-response-handler": "0.5.0",
30
+ "@web-ts-toolkit/http-errors": "0.5.0",
31
+ "@web-ts-toolkit/utils": "0.5.0",
26
32
  "express": "^5.2.1"
27
33
  },
28
34
  "author": "Junmin Ahn",
29
35
  "bugs": {
30
36
  "url": "https://github.com/egose/web-ts-toolkit/issues"
31
37
  },
32
- "engines": {
33
- "node": ">=20"
34
- },
35
38
  "license": "Apache-2.0",
36
39
  "repository": {
37
40
  "type": "git",