json-server
Advanced tools
Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4
#!/usr/bin/env node | ||
import { readFileSync } from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { extname, join } from 'node:path'; | ||
import { parseArgs } from 'node:util'; | ||
@@ -9,3 +9,4 @@ import { watch } from 'chokidar'; | ||
import { createApp } from './app.js'; | ||
import { Observer } from './observer.js'; | ||
import { JSON5File } from './JSON5File.js'; | ||
import { Observer } from './Observer.js'; | ||
// Parse args | ||
@@ -56,3 +57,9 @@ const { values, positionals } = parseArgs({ | ||
// Set up database | ||
const adapter = new JSONFile(file); | ||
let adapter; | ||
if (extname(file) === '.json5') { | ||
adapter = new JSON5File(file); | ||
} | ||
else { | ||
adapter = new JSONFile(file); | ||
} | ||
const observer = new Observer(adapter); | ||
@@ -59,0 +66,0 @@ const db = new Low(observer, {}); |
{ | ||
"name": "json-server", | ||
"version": "1.0.0-alpha.3", | ||
"version": "1.0.0-alpha.4", | ||
"description": "", | ||
@@ -18,3 +18,3 @@ "type": "module", | ||
"build": "rm -rf lib && tsc && npm run css", | ||
"test": "node --import tsx/esm --test src/**/*.test.ts", | ||
"test": "npm run css && node --import tsx/esm --test src/*.test.ts", | ||
"lint": "eslint src --ext .ts --ignore-path .gitignore", | ||
@@ -47,2 +47,3 @@ "prepare": "husky install", | ||
"inflection": "^3.0.0", | ||
"json5": "^2.2.3", | ||
"lowdb": "^6.1.1", | ||
@@ -49,0 +50,0 @@ "milliparsec": "^2.3.0", |
@@ -15,11 +15,14 @@ # json-server | ||
> [!TIP] | ||
> You can also use [json5](https://json5.org/) format by creating a `db.json5` instead | ||
```json | ||
{ | ||
"posts": [ | ||
{ "id": "1", "title": "string" }, | ||
{ "id": "2", "title": "some post" } | ||
{ "id": "1", "title": "a title" }, | ||
{ "id": "2", "title": "another title" } | ||
], | ||
"comments": [ | ||
{ "id": "1", "text": "some text", "postId": "1" }, | ||
{ "id": "2", "text": "some text", "postId": "1" } | ||
{ "id": "1", "text": "a comment about post 1", "postId": "1" }, | ||
{ "id": "2", "text": "another comment about post 1", "postId": "1" } | ||
] | ||
@@ -31,2 +34,7 @@ } | ||
json-server db.json | ||
curl -H "Accept: application/json" -X GET http://localhost:3000/posts/1 | ||
{ | ||
"id": "1", | ||
"title": "a title" | ||
} | ||
``` | ||
@@ -33,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
165396
19
1806
121
1
11
+ Addedjson5@^2.2.3
+ Addedjson5@2.2.3(transitive)