Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-server

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-server - npm Package Compare versions

Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4

lib/JSON5File.d.ts

13

lib/bin.js
#!/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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc