db-json-cli 1.0.1 β†’ 1.0.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.
Files changed (2) hide show
  1. package/README.md +90 -64
  2. package/package.json +18 -2
package/README.md CHANGED
@@ -1,108 +1,134 @@
1
- # πŸ“¦ db-json-cli
1
+ # db-json-cli
2
2
 
3
- > Lightweight local JSON API server with JWT auth + private/public route control
4
- > μ™„μ „ν•œ 둜컬 λͺ©μ„œλ²„ + 인증/κΆŒν•œ μ œμ–΄ CLI 툴
3
+ JSON file 기반의 λ°±μ—”λ“œ μ„œλ²„ + JWT 인증 + CLI 도ꡬ
5
4
 
6
- --------------
5
+ ---
7
6
 
8
- ## πŸš€ μ„€μΉ˜
7
+ ## πŸ“¦ μ„€μΉ˜
9
8
 
9
+ ```bash
10
10
  npm install -g db-json-cli
11
- λ˜λŠ” ν”„λ‘œμ νŠΈ λ‚΄λΆ€μ—μ„œ:
11
+ ```
12
12
 
13
- bash
14
- npm install db-json-cli
15
- βš™οΈ μ‚¬μš©λ²•
16
- 1️⃣ μ„œλ²„ μ‹œμž‘
17
- db-json-cli --db ./db.json --port 4000
18
- κΈ°λ³Έ ν¬νŠΈλŠ” 4000, JSON 파일 κ²½λ‘œλŠ” ./db.json
13
+ ---
19
14
 
20
- 2️⃣ κΈ°λ³Έ JSON ꡬ쑰 μ˜ˆμ‹œ
15
+ ## πŸš€ μ‚¬μš©λ²•
21
16
 
17
+ ### 1. μ„œλ²„ μ‹œμž‘
18
+
19
+ ```bash
20
+ db-json-cli --db ./path/to/db.json --port 4000
21
+ ```
22
+
23
+ - `--db` : JSON 파일 경둜
24
+ - `--port` : μ„œλ²„ 포트 (κΈ°λ³Έ 4000)
25
+
26
+ ---
27
+
28
+ ### 2. JSON ꡬ쑰
29
+
30
+ ```json
22
31
  {
23
- "users": [],
24
- "list": [
25
- { "id": 1, "title": "Private item" },
26
- { "id": 2, "title": "Visible to authenticated users only" }
27
- ],
28
- "public": [
29
- { "id": 1, "title": "Publicly visible item" }
30
- ],
31
- "rules": {
32
- "list": "private",
33
- "public": "public"
34
- }
32
+ "users": [],
33
+ "list": [{ "id": 1, "title": "Private item" }],
34
+ "public": [{ "id": 1, "title": "Public item" }],
35
+ "rules": {
36
+ "list": "private",
37
+ "public": "public"
38
+ }
35
39
  }
40
+ ```
41
+
42
+ - `users` : νšŒμ› 정보 μ €μž₯
43
+ - `list` : 인증 ν•„μš” 데이터 ex)
44
+ - `public` : λˆ„κ΅¬λ‚˜ μ ‘κ·Ό κ°€λŠ₯ν•œ 데이터 ex)
45
+ - `rules` : 각 ν‚€μ˜ μ ‘κ·Ό κΆŒν•œ μ„€μ • (`private` λ˜λŠ” `public`)
46
+
47
+ ---
36
48
 
37
- rules 객체에 각 μ»¬λ ‰μ…˜μ˜ μ ‘κ·Ό κΆŒν•œ(public / private)을 μ§€μ •ν•©λ‹ˆλ‹€.
49
+ ### 3. API
38
50
 
39
- ### πŸ” μ—”λ“œν¬μΈνŠΈ
51
+ #### νšŒμ›κ°€μž…
40
52
 
41
- βœ… νšŒμ›κ°€μž…
53
+ ```http
42
54
  POST /register
55
+ Content-Type: application/json
43
56
 
44
- μš”μ²­ μ˜ˆμ‹œ
45
57
  {
46
- "email": "user@test.com",
47
- "password": "1234",
48
- "name": "tester"
58
+ "email": "example@example.com",
59
+ "password": "password123",
60
+ "name": "홍길동"
49
61
  }
62
+ ```
50
63
 
51
- 응닡 μ˜ˆμ‹œ
64
+ 응닡:
65
+
66
+ ```json
52
67
  {
53
- "accessToken": "xxxxx.yyyyy.zzzzz",
54
- "refreshToken": "xxxxx.yyyyy.zzzzz"
68
+ "accessToken": "...",
69
+ "refreshToken": "..."
55
70
  }
71
+ ```
72
+
73
+ ---
56
74
 
57
- βœ… 둜그인
75
+ #### 둜그인
76
+
77
+ ```http
58
78
  POST /login
79
+ Content-Type: application/json
59
80
 
60
- μš”μ²­ μ˜ˆμ‹œ
61
81
  {
62
- "email": "user@test.com",
63
- "password": "1234"
82
+ "email": "example@example.com",
83
+ "password": "password123"
64
84
  }
85
+ ```
86
+
87
+ 응닡:
65
88
 
66
- 응닡 μ˜ˆμ‹œ
89
+ ```json
67
90
  {
68
- "accessToken": "xxxxx.yyyyy.zzzzz",
69
- "refreshToken": "xxxxx.yyyyy.zzzzz"
91
+ "accessToken": "...",
92
+ "refreshToken": "..."
70
93
  }
94
+ ```
71
95
 
96
+ ---
72
97
 
98
+ #### 데이터 쑰회
73
99
 
74
- #### πŸ”’ Private 데이터 쑰회 (인증 ν•„μš”)
75
- GET /list
76
- λ˜λŠ” νŠΉμ • ID만 쑰회:
100
+ - **인증 ν•„μš” 데이터** (`private`)
101
+
102
+ ```http
77
103
  GET /list/1
78
- μš”μ²­ 헀더에 JWT 토큰 ν•„μš”:
79
104
  Authorization: Bearer <accessToken>
105
+ ```
80
106
 
107
+ - **인증 λΆˆν•„μš” 데이터** (`public`)
81
108
 
82
- ##### 🌐 Public 데이터 쑰회 (λˆ„κ΅¬λ‚˜ κ°€λŠ₯)
109
+ ```http
110
+ GET /public/1
111
+ ```
83
112
 
84
- GET /public
85
- λ˜λŠ”:
113
+ - μ—¬λŸ¬ μ•„μ΄ν…œ 쑰회 μ‹œ λ²”μœ„ μ§€μ • κ°€λŠ₯
86
114
 
87
- GET /public/1
115
+ ```http
116
+ GET /list?from=1&to=10
117
+ ```
88
118
 
89
- πŸ“¨ 데이터 μΆ”κ°€ (POST)
90
- POST /list
91
- POST /public
119
+ ---
92
120
 
93
- μ˜ˆμ‹œ
94
- { "id": 3, "title": "New item" }
121
+ ### 4. CLI μ˜΅μ…˜
95
122
 
96
- 🧠 CLI μ˜΅μ…˜
123
+ ```bash
124
+ db-json-cli --db ./src/db/db.json --port 5000
125
+ ```
97
126
 
98
- --db JSON DB 파일 경둜 ./db.json
99
- --port μ„œλ²„ 포트 번호 4000
100
- --watch 파일 λ³€κ²½ μ‹œ μžλ™ λ¦¬λ‘œλ“œ false
127
+ - `--db` : JSON 파일 경둜
128
+ - `--port` : 포트
101
129
 
102
- πŸ“„ μ˜ˆμ‹œ μ‹€ν–‰
103
- db-json-cli --db ./example.json --port 5000
104
- /register, /login 인증 지원
130
+ ---
105
131
 
106
- /list, /public μ ‘κ·Ό μ œμ–΄
132
+ ### 5. λΌμ΄μ„ μŠ€
107
133
 
108
- μ‹€μ‹œκ°„ JSON λ³€κ²½ μžλ™ 반영 (watch μ˜΅μ…˜ μ‹œ)
134
+ MIT Β© 2025 μ •μ§€ν—Œ
package/package.json CHANGED
@@ -1,8 +1,24 @@
1
1
  {
2
2
  "name": "db-json-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
- "description": "JSON file based backend server with JWT auth and CLI",
5
+ "description": "Lightweight JSON-based backend server with JWT authentication and CLI support",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/JEONG-JI-HEON/db-json-cli.git"
9
+ },
10
+ "homepage": "https://github.com/JEONG-JI-HEON/db-json-cli#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/JEONG-JI-HEON/db-json-cli/issues"
13
+ },
14
+ "keywords": [
15
+ "json-server",
16
+ "cli",
17
+ "jwt",
18
+ "mock-server",
19
+ "express",
20
+ "api"
21
+ ],
6
22
  "bin": {
7
23
  "db-json-cli": "./bin/db-json-cli.js"
8
24
  },