@wooksjs/express-adapter 0.0.1-alpha.0 → 0.0.1-alpha.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 +2 -1
- package/dist/index.cjs +7 -3
- package/dist/index.mjs +7 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,11 +15,12 @@ Want to use [Wooks Composables](https://github.com/wooksjs/composables) but your
|
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
18
|
-
`npm install @wooksjs/express-adapter`
|
|
18
|
+
`npm install @wooksjs/express-adapter @wooksjs/composables`
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
+
import express from 'express'
|
|
23
24
|
import { applyExpressAdapter } from '@wooksjs/express-adapter'
|
|
24
25
|
import { useBody } from '@wooksjs/body'
|
|
25
26
|
import { useRouteParams, WooksError } from '@wooksjs/composables'
|
package/dist/index.cjs
CHANGED
|
@@ -6,8 +6,11 @@ const methods = [
|
|
|
6
6
|
"get",
|
|
7
7
|
"post",
|
|
8
8
|
"delete",
|
|
9
|
+
"put",
|
|
9
10
|
"patch",
|
|
10
|
-
"options"
|
|
11
|
+
"options",
|
|
12
|
+
"head",
|
|
13
|
+
"all"
|
|
11
14
|
];
|
|
12
15
|
function applyExpressAdapter(app) {
|
|
13
16
|
const responder = composables.createWooksResponder();
|
|
@@ -17,9 +20,10 @@ function applyExpressAdapter(app) {
|
|
|
17
20
|
try {
|
|
18
21
|
const result = await fn();
|
|
19
22
|
restoreCtx();
|
|
20
|
-
responder.respond(result);
|
|
23
|
+
await responder.respond(result);
|
|
21
24
|
} catch (e) {
|
|
22
|
-
|
|
25
|
+
restoreCtx();
|
|
26
|
+
await responder.respond(e);
|
|
23
27
|
}
|
|
24
28
|
clearCtx();
|
|
25
29
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -4,8 +4,11 @@ const methods = [
|
|
|
4
4
|
"get",
|
|
5
5
|
"post",
|
|
6
6
|
"delete",
|
|
7
|
+
"put",
|
|
7
8
|
"patch",
|
|
8
|
-
"options"
|
|
9
|
+
"options",
|
|
10
|
+
"head",
|
|
11
|
+
"all"
|
|
9
12
|
];
|
|
10
13
|
function applyExpressAdapter(app) {
|
|
11
14
|
const responder = createWooksResponder();
|
|
@@ -15,9 +18,10 @@ function applyExpressAdapter(app) {
|
|
|
15
18
|
try {
|
|
16
19
|
const result = await fn();
|
|
17
20
|
restoreCtx();
|
|
18
|
-
responder.respond(result);
|
|
21
|
+
await responder.respond(result);
|
|
19
22
|
} catch (e) {
|
|
20
|
-
|
|
23
|
+
restoreCtx();
|
|
24
|
+
await responder.respond(e);
|
|
21
25
|
}
|
|
22
26
|
clearCtx();
|
|
23
27
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wooksjs/express-adapter",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
4
|
"description": "Express Adapter for Wooks Composables",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/wooksjs/express-adapter#readme",
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@wooksjs/composables": "^0.0.1-alpha.
|
|
62
|
+
"@wooksjs/composables": "^0.0.1-alpha.12",
|
|
63
63
|
"express": "^4.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@types/node": "^18.11.0",
|
|
70
70
|
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
71
71
|
"@typescript-eslint/parser": "^5.0.0",
|
|
72
|
-
"@wooksjs/composables": "^0.0.1-alpha.
|
|
72
|
+
"@wooksjs/composables": "^0.0.1-alpha.12",
|
|
73
73
|
"conventional-changelog": "^3.1.24",
|
|
74
74
|
"conventional-changelog-cli": "^2.1.1",
|
|
75
75
|
"enquirer": "^2.3.6",
|