json-server 1.0.0-beta.1 → 1.0.0-beta.12

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/package.json CHANGED
@@ -1,59 +1,73 @@
1
1
  {
2
2
  "name": "json-server",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "",
5
- "type": "module",
5
+ "keywords": [
6
+ "JSON",
7
+ "server",
8
+ "fake",
9
+ "REST",
10
+ "API",
11
+ "prototyping",
12
+ "mock",
13
+ "mocking",
14
+ "test",
15
+ "testing",
16
+ "rest",
17
+ "data",
18
+ "dummy"
19
+ ],
20
+ "license": "MIT",
21
+ "author": "typicode <typicode@gmail.com>",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/typicode/json-server.git"
25
+ },
6
26
  "bin": {
7
27
  "json-server": "lib/bin.js"
8
28
  },
9
- "types": "lib",
10
29
  "files": [
11
30
  "lib",
12
- "views"
31
+ "views",
32
+ "schema.json"
13
33
  ],
14
- "engines": {
15
- "node": ">=18.3"
16
- },
17
- "scripts": {
18
- "dev": "tsx watch src/bin.ts fixtures/db.json",
19
- "build": "rm -rf lib && tsc",
20
- "test": "node --import tsx/esm --test src/*.test.ts",
21
- "lint": "eslint src --ext .ts --ignore-path .gitignore",
22
- "prepare": "husky",
23
- "prepublishOnly": "npm run build"
24
- },
25
- "keywords": [],
26
- "author": "typicode <typicode@gmail.com>",
27
- "license": "SEE LICENSE IN ./LICENSE",
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/typicode/json-server.git"
34
+ "type": "module",
35
+ "dependencies": {
36
+ "@tinyhttp/app": "^3.0.1",
37
+ "@tinyhttp/cors": "^2.0.1",
38
+ "@tinyhttp/logger": "^2.1.0",
39
+ "chalk": "^5.6.2",
40
+ "chokidar": "^5.0.0",
41
+ "dot-prop": "^10.1.0",
42
+ "eta": "^4.5.0",
43
+ "inflection": "^3.0.2",
44
+ "json5": "^2.2.3",
45
+ "lowdb": "^7.0.1",
46
+ "milliparsec": "^5.1.0",
47
+ "sirv": "^3.0.2",
48
+ "sort-on": "^7.0.0"
31
49
  },
32
50
  "devDependencies": {
33
- "@sindresorhus/tsconfig": "^5.0.0",
34
- "@tailwindcss/typography": "^0.5.13",
35
- "@types/node": "^20.14.1",
36
- "@typicode/eslint-config": "^2.0.0",
37
- "concurrently": "^8.2.2",
51
+ "@types/node": "^25.0.8",
52
+ "concurrently": "^9.2.1",
38
53
  "get-port": "^7.1.0",
39
- "husky": "^9.0.11",
54
+ "husky": "^9.1.7",
55
+ "oxfmt": "^0.24.0",
56
+ "oxlint": "^1.39.0",
40
57
  "tempy": "^3.1.0",
41
- "tsx": "^4.11.2",
42
- "type-fest": "^4.18.3",
43
- "typescript": "^5.4.5"
58
+ "type-fest": "^5.4.0",
59
+ "typescript": "^5.9.3"
44
60
  },
45
- "dependencies": {
46
- "@tinyhttp/app": "^2.2.3",
47
- "@tinyhttp/cors": "^2.0.0",
48
- "chalk": "^5.3.0",
49
- "chokidar": "^3.6.0",
50
- "dot-prop": "^9.0.0",
51
- "eta": "^3.4.0",
52
- "inflection": "^3.0.0",
53
- "json5": "^2.2.3",
54
- "lowdb": "^7.0.1",
55
- "milliparsec": "^2.3.0",
56
- "sirv": "^2.0.4",
57
- "sort-on": "^6.0.0"
61
+ "engines": {
62
+ "node": ">=22.12.0"
63
+ },
64
+ "scripts": {
65
+ "dev": "node --watch --experimental-strip-types src/bin.ts fixtures/db.json",
66
+ "build": "rm -rf lib && tsc",
67
+ "typecheck": "tsc --noEmit",
68
+ "test": "node --experimental-strip-types --test src/*.test.ts",
69
+ "lint": "oxlint src",
70
+ "fmt": "oxfmt",
71
+ "fmt:check": "oxfmt --check"
58
72
  }
59
- }
73
+ }
package/schema.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": {
5
+ "oneOf": [
6
+ { "type": "array" },
7
+ { "type": "object" }
8
+ ]
9
+ }
10
+ }
package/views/index.html CHANGED
@@ -1,97 +1,95 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <style>
7
+ html {
8
+ font-size: 16px;
9
+ line-height: 1.5;
10
+ background-color: #fff;
11
+ color: #000;
12
+ }
3
13
 
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <style>
8
- html {
9
- font-size: 16px;
10
- line-height: 1.5;
11
- background-color: #fff;
12
- color: #000;
13
- }
14
-
15
- body {
16
- margin: 0 auto;
17
- max-width: 720px;
18
- padding: 0 16px;
19
- font-family: sans-serif;
20
- }
21
-
22
- a {
23
- color: #db2777;
24
- text-decoration: none;
25
- }
14
+ body {
15
+ margin: 0 auto;
16
+ max-width: 720px;
17
+ padding: 0 16px;
18
+ font-family: sans-serif;
19
+ }
26
20
 
27
- header {
28
- margin-bottom: 32px;
29
- padding: 16px 0;
30
- }
21
+ a {
22
+ color: #db2777;
23
+ text-decoration: none;
24
+ }
31
25
 
32
- nav {
33
- display: flex;
34
- justify-content: space-between;
35
- }
26
+ header {
27
+ margin-bottom: 32px;
28
+ padding: 16px 0;
29
+ }
36
30
 
37
- nav div a {
38
- margin-left: 16px;
39
- }
31
+ nav {
32
+ display: flex;
33
+ justify-content: space-between;
34
+ }
40
35
 
41
- ul {
42
- margin: 0;
43
- padding: 0;
44
- list-style: none;
45
- }
36
+ nav div a {
37
+ margin-left: 16px;
38
+ }
46
39
 
47
- li {
48
- margin-bottom: 8px;
49
- }
40
+ ul {
41
+ margin: 0;
42
+ padding: 0;
43
+ list-style: none;
44
+ }
50
45
 
51
- /* Dark mode styles */
52
- @media (prefers-color-scheme: dark) {
53
- html {
54
- background-color: #1e293b;
55
- color: #fff;
46
+ li {
47
+ margin-bottom: 8px;
56
48
  }
57
49
 
58
- a {
50
+ /* Dark mode styles */
51
+ @media (prefers-color-scheme: dark) {
52
+ html {
53
+ background-color: #1e293b;
54
+ color: #fff;
55
+ }
59
56
 
57
+ a {
58
+ }
60
59
  }
61
- }
62
-
63
- </style>
64
- </head>
60
+ </style>
61
+ </head>
65
62
 
66
- <body>
67
- <header>
68
- <nav>
69
- <strong>JSON Server</strong>
70
- <div>
71
- <a href="https://github.com/typicode/json-server">Docs</a>
72
- <a href="https://github.com/sponsors/typicode">♡ Sponsor</a>
73
- </div>
74
- </nav>
75
- </header>
76
- <main class="my-12">
77
- <p class="bg-gradient-to-r from-purple-500 via-pink-500 to-red-500 text-transparent bg-clip-text">✧*。٩(ˊᗜˋ*)و✧*。</p>
78
- <% if (Object.keys(it.data).length===0) { %>
63
+ <body>
64
+ <header>
65
+ <nav>
66
+ <strong>JSON Server</strong>
67
+ <div>
68
+ <a href="https://github.com/typicode/json-server">Docs</a>
69
+ <a href="https://github.com/sponsors/typicode">♡ Sponsor</a>
70
+ </div>
71
+ </nav>
72
+ </header>
73
+ <main class="my-12">
74
+ <p
75
+ class="bg-gradient-to-r from-purple-500 via-pink-500 to-red-500 text-transparent bg-clip-text"
76
+ >
77
+ ✧*。٩(ˊᗜˋ*)و✧*。
78
+ </p>
79
+ <% if (Object.keys(it.data).length===0) { %>
79
80
  <p>No resources found in JSON file</p>
80
- <% } %>
81
- <% Object.entries(it.data).forEach(function([name]) { %>
81
+ <% } %> <% Object.entries(it.data).forEach(function([name]) { %>
82
82
  <ul>
83
83
  <li>
84
84
  <a href="<%= name %>">/<%= name %></a>
85
85
  <span>
86
- <% if (Array.isArray(it.data[name])) { %>
87
- - <%= it.data[name].length %>
88
- <%= it.data[name].length> 1 ? 'items' : 'item' %>
86
+ <% if (Array.isArray(it.data[name])) { %> - <%= it.data[name].length %> <%=
87
+ it.data[name].length> 1 ? 'items' : 'item' %>
89
88
  </span>
90
89
  <% } %>
91
90
  </li>
92
91
  </ul>
93
- <% }) %>
94
- </main>
95
- </body>
96
-
97
- </html>
92
+ <% }) %>
93
+ </main>
94
+ </body>
95
+ </html>
package/lib/app.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { App } from '@tinyhttp/app';
2
- import { Low } from 'lowdb';
3
- import { Data } from './service.js';
4
- export type AppOptions = {
5
- logger?: boolean;
6
- static?: string[];
7
- };
8
- export declare function createApp(db: Low<Data>, options?: AppOptions): App<import("@tinyhttp/app").Request, import("@tinyhttp/app").Response<unknown>>;
package/lib/bin.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/lib/observer.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { Adapter } from 'lowdb';
2
- export declare class Observer<T> {
3
- #private;
4
- onReadStart: () => void;
5
- onReadEnd: (data: T | null) => void;
6
- onWriteStart: () => void;
7
- onWriteEnd: () => void;
8
- constructor(adapter: Adapter<T>);
9
- read(): Promise<T | null>;
10
- write(arg: T): Promise<void>;
11
- }
package/lib/service.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import { Low } from 'lowdb';
2
- export type Item = Record<string, unknown>;
3
- export type Data = Record<string, Item[] | Item>;
4
- export declare function isItem(obj: unknown): obj is Item;
5
- export declare function isData(obj: unknown): obj is Record<string, Item[]>;
6
- export type PaginatedItems = {
7
- first: number;
8
- prev: number | null;
9
- next: number | null;
10
- last: number;
11
- pages: number;
12
- items: number;
13
- data: Item[];
14
- };
15
- export declare class Service {
16
- #private;
17
- constructor(db: Low<Data>);
18
- has(name: string): boolean;
19
- findById(name: string, id: string, query: {
20
- _embed?: string[] | string;
21
- }): Item | undefined;
22
- find(name: string, query?: {
23
- [key: string]: unknown;
24
- _embed?: string | string[];
25
- _sort?: string;
26
- _start?: number;
27
- _end?: number;
28
- _limit?: number;
29
- _page?: number;
30
- _per_page?: number;
31
- }): Item[] | PaginatedItems | Item | undefined;
32
- create(name: string, data?: Omit<Item, 'id'>): Promise<Item | undefined>;
33
- update(name: string, body?: Item): Promise<Item | undefined>;
34
- patch(name: string, body?: Item): Promise<Item | undefined>;
35
- updateById(name: string, id: string, body?: Item): Promise<Item | undefined>;
36
- patchById(name: string, id: string, body?: Item): Promise<Item | undefined>;
37
- destroyById(name: string, id: string, dependent?: string | string[]): Promise<Item | undefined>;
38
- }
File without changes