@kollors/deep-json-server 0.2.2 → 0.2.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 +1 -1
- package/package.json +2 -1
- package/src/utils.js +2 -11
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The default address is `http://127.0.0.1:4001`. You can also pass `--host` and `
|
|
|
33
33
|
|
|
34
34
|
## Example database
|
|
35
35
|
|
|
36
|
-
This example is based on a movie catalog.
|
|
36
|
+
This example is based on a movie catalog. The genre names are real film genres, while `Gangster film` demonstrates a self-referencing subgenre.
|
|
37
37
|
|
|
38
38
|
```json
|
|
39
39
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kollors/deep-json-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "JSON mock server with deep filters and recursive relationship embedding",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"fastify": "^5.12.1",
|
|
28
28
|
"lowdb": "^7.0.1",
|
|
29
|
+
"pluralize": "^8.0.0",
|
|
29
30
|
"yaml": "^2.8.1"
|
|
30
31
|
},
|
|
31
32
|
"repository": {
|
package/src/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { realpathSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import pluralize from 'pluralize';
|
|
4
5
|
|
|
5
6
|
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
6
7
|
|
|
@@ -45,16 +46,6 @@ export const resolveDatabasePath = (databasePath) => {
|
|
|
45
46
|
return resolve(databasePath);
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
export const singularize = (value) =>
|
|
49
|
-
if (value === 'clothes' || value === 'movies') {
|
|
50
|
-
return value === 'movies' ? 'movie' : value;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (value.endsWith('ies')) {
|
|
54
|
-
return `${value.slice(0, -3)}y`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return value.endsWith('s') ? value.slice(0, -1) : value;
|
|
58
|
-
};
|
|
49
|
+
export const singularize = (value) => pluralize.singular(value);
|
|
59
50
|
|
|
60
51
|
export const toPascalCase = (value) => value.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join('');
|