jaypie 1.0.0 → 1.0.2
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 +7 -5
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -232,7 +232,7 @@ throw MultiError(errors);
|
|
|
232
232
|
| `TeapotError` | 418 | RFC 2324 section-2.3.2 |
|
|
233
233
|
| `UnavailableError` | 503 | The thing you are looking for cannot come to the phone right now |
|
|
234
234
|
| `UnhandledError` | 500 | An error that should have been handled wasn't |
|
|
235
|
-
| `UnreachableCodeError` | 500 |
|
|
235
|
+
| `UnreachableCodeError` | 500 | Should not be possible |
|
|
236
236
|
|
|
237
237
|
##### Special Errors
|
|
238
238
|
|
|
@@ -251,6 +251,8 @@ ALWAYS internal to the app, NEVER something the client did
|
|
|
251
251
|
* If an unexpected error escapes the handler, Jaypie returns this when it is caught
|
|
252
252
|
* Unreachable
|
|
253
253
|
* In theory the block is literally not reachable and we want to put something there to make sure it stays that way
|
|
254
|
+
* For example, a complicated chain of `if`/`else` that should always return and cover all cases, may throw this as the last `else`
|
|
255
|
+
* A configuration error means what happened was possible but should not have happened, an unreachable error means it should not have been possible
|
|
254
256
|
|
|
255
257
|
### Functions
|
|
256
258
|
|
|
@@ -295,6 +297,7 @@ if (envBoolean("AWESOME", { defaultValue: true })) {
|
|
|
295
297
|
#### `force`
|
|
296
298
|
|
|
297
299
|
Coerce a value into a type or throw an error.
|
|
300
|
+
Forcing arrays is the primary use case.
|
|
298
301
|
|
|
299
302
|
```javascript
|
|
300
303
|
import { force } from "jaypie";
|
|
@@ -304,10 +307,9 @@ argument = force([thing], Array);
|
|
|
304
307
|
// argument = [thing]
|
|
305
308
|
```
|
|
306
309
|
|
|
307
|
-
|
|
310
|
+
`force` supports Array, Object, and String.
|
|
308
311
|
|
|
309
312
|
```javascript
|
|
310
|
-
// force supports Array, Object, and String
|
|
311
313
|
argument = force(argument, Array);
|
|
312
314
|
argument = force(argument, Object, "key");
|
|
313
315
|
argument = force(argument, String, "default");
|
|
@@ -343,7 +345,7 @@ The code for placeholders was written by Chris Ferdinandi and distributed under
|
|
|
343
345
|
import { validate, VALIDATE } from "jaypie";
|
|
344
346
|
|
|
345
347
|
validate(argument, {
|
|
346
|
-
type:
|
|
348
|
+
type: VALIDATE.ANY,
|
|
347
349
|
falsy: false, // When `true`, allows "falsy" values that match the type (e.g., `0`, `""`)
|
|
348
350
|
required: true, // When `false`, allows `undefined` as a valid value
|
|
349
351
|
throws: true // When `false`, returns `false` instead of throwing error
|
|
@@ -407,7 +409,7 @@ Returns `true` to validate the request. Throw an error or return `false` to reje
|
|
|
407
409
|
|
|
408
410
|
Called before the handler (e.g., connect to a database). Throw an error to halt execution.
|
|
409
411
|
|
|
410
|
-
|
|
412
|
+
##### `handler: async Function`
|
|
411
413
|
|
|
412
414
|
The main function to handle the request. Throw an error to halt execution.
|
|
413
415
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jaypie",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"author": "Finlayson Studio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -17,25 +17,25 @@
|
|
|
17
17
|
"test:spec:mongoose.package": "vitest run ./src/__tests__/mongoose.package.spec.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@jaypie/core": "^0.
|
|
20
|
+
"@jaypie/core": "^1.0.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@jaypie/testkit": "^1.0.
|
|
23
|
+
"@jaypie/testkit": "^1.0.3",
|
|
24
24
|
"eslint": "^8.57.0",
|
|
25
25
|
"eslint-config-prettier": "^9.1.0",
|
|
26
26
|
"eslint-plugin-import": "^2.29.1",
|
|
27
27
|
"eslint-plugin-prettier": "^5.1.3",
|
|
28
|
-
"eslint-plugin-vitest": "^0.
|
|
28
|
+
"eslint-plugin-vitest": "^0.4.0",
|
|
29
29
|
"hygen": "^6.2.11",
|
|
30
30
|
"jest-extended": "^4.0.2",
|
|
31
31
|
"prettier": "^3.2.5",
|
|
32
|
-
"sort-package-json": "^2.
|
|
32
|
+
"sort-package-json": "^2.9.0",
|
|
33
33
|
"vitest": "^1.4.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@jaypie/aws": "^0.
|
|
37
|
-
"@jaypie/lambda": "^0.
|
|
38
|
-
"@jaypie/mongoose": "^0.
|
|
36
|
+
"@jaypie/aws": "^1.0.0",
|
|
37
|
+
"@jaypie/lambda": "^1.0.0",
|
|
38
|
+
"@jaypie/mongoose": "^1.0.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@jaypie/aws": {
|