dangkhoa2016 commited on
Commit
b8e6260
·
1 Parent(s): 42e30c2

docs: add project highlights and similar project note

Browse files

- Add a highlights section to both README files
- Link the related dashboard UI project

Files changed (2) hide show
  1. README.md +27 -1
  2. README.vi.md +27 -1
README.md CHANGED
@@ -1,9 +1,27 @@
1
- # json-api-server
 
 
 
 
 
 
2
 
3
  > 🌐 Language / Ngôn ngữ: **English** | [Tiếng Việt](README.vi.md)
4
 
5
  A JSONPlaceholder-compatible REST API built mostly with **Node.js built-ins** — the only runtime dependency is `argon2` for admin password hashing. Uses `node:sqlite` for storage and a custom Redis client implemented over the raw RESP protocol via TCP sockets.
6
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  ## Technologies Used
8
 
9
  - **Node.js >= 22** — runtime with built-in `node:sqlite`, `node:http`, `node:net`, etc.
@@ -372,6 +390,14 @@ npm run test:coverage # With coverage report (100% across all metrics)
372
 
373
  See [tests/README.md](tests/README.md) for full documentation.
374
 
 
 
 
 
 
 
 
 
375
  ## License
376
 
377
  [MIT](LICENSE) — Copyright (c) 2026 Dang Khoa <i.am@dangkhoa.dev>
 
1
+ # Nodejs JSON API Server
2
+
3
+ [![Nodejs 22.x](https://img.shields.io/badge/Nodejs-22.x-339933?style=flat&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
4
+ [![Nodejs 24.x](https://img.shields.io/badge/Nodejs-24.x-339933?style=flat&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
5
+ [![Nodejs 26.x](https://img.shields.io/badge/Nodejs-26.x-339933?style=flat&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
6
+ [![CI](https://github.com/dangkhoa2016/NodeJs-JSON-API-Server/actions/workflows/test.yml/badge.svg)](https://github.com/dangkhoa2016/NodeJs-JSON-API-Server/actions/workflows/test.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
 
9
  > 🌐 Language / Ngôn ngữ: **English** | [Tiếng Việt](README.vi.md)
10
 
11
  A JSONPlaceholder-compatible REST API built mostly with **Node.js built-ins** — the only runtime dependency is `argon2` for admin password hashing. Uses `node:sqlite` for storage and a custom Redis client implemented over the raw RESP protocol via TCP sockets.
12
 
13
+ ## Highlights
14
+
15
+ - **Zero-framework, minimal dependencies** — Only **1 production dependency** (`argon2`). HTTP, SQLite, networking — all Node.js built-ins. No Express, no ORM, no Redis driver.
16
+ - **Custom Redis client from scratch** — A full Redis client implementing the **RESP protocol** over raw TCP sockets. Supports `AUTH`, `SELECT`, `EVAL` (Lua scripts), URL connection strings, and automatic reconnect — all in ~200 lines.
17
+ - **100% test coverage** — **250 tests across 14 files** achieve 100% on statements, branches, functions, and lines. Integration tests run against a real HTTP server + SQLite; unit tests use dependency injection and CJS cache mocking.
18
+ - **Multi-tier rate limiting** — Three-tier fallback: Redis (atomic Lua) → in-memory (LRU, 10k entries) → allow-all. Features a circuit breaker (3 failures → 30s open), CIDR-based trusted proxy extraction, and escalating block durations (5m → 20m → 1h).
19
+ - **Production-hardened Docker** — Multi-stage build, **non-root user**, automated DB setup on start, `.env` files excluded. Dotenv is skipped in production — all config comes via environment variables.
20
+ - **Runtime configuration** — Update rate-limit and Redis settings via admin API **without restarting**. Changes take immediate effect through in-memory overrides.
21
+ - **Argon2 security** — Admin passwords hashed with argon2, results cached with 5s TTL and 1k-entry LRU. SQL injection prevented via column whitelisting and LIKE escaping. Body size limited to 1 MB.
22
+ - **Built-in dev server with file watching** — `npm run dev` uses Node's native `--watch` flag. No Nodemon, no chokidar, no extra dependencies.
23
+ - **Bilingual documentation** — Full docs in **English and Vietnamese** for README, testing guide, and technical architecture.
24
+
25
  ## Technologies Used
26
 
27
  - **Node.js >= 22** — runtime with built-in `node:sqlite`, `node:http`, `node:net`, etc.
 
390
 
391
  See [tests/README.md](tests/README.md) for full documentation.
392
 
393
+ ## Similar Project
394
+
395
+ If you like this server but want a **dashboard UI** built with **Tailwind CSS**, check out:
396
+
397
+ - **GitHub:** [JSON-API-Server-With-Dashboard-UI](https://github.com/dangkhoa2016/JSON-API-Server-With-Dashboard-UI)
398
+
399
+ It provides the same JSONPlaceholder-compatible API with an intuitive web interface — highly recommended!
400
+
401
  ## License
402
 
403
  [MIT](LICENSE) — Copyright (c) 2026 Dang Khoa <i.am@dangkhoa.dev>
README.vi.md CHANGED
@@ -1,9 +1,27 @@
1
- # json-api-server
 
 
 
 
 
 
2
 
3
  > 🌐 Language / Ngôn ngữ: [English](README.md) | **Tiếng Việt**
4
 
5
  Một REST API tương thích JSONPlaceholder, được xây dựng chủ yếu bằng **Node.js built-ins** — dependency runtime duy nhất là `argon2` dùng để băm mật khẩu admin. Dùng `node:sqlite` để lưu trữ và một Redis client tự xây dựng trên giao thức RESP qua TCP sockets.
6
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  ## Công nghệ sử dụng
8
 
9
  - **Node.js >= 22** — runtime với `node:sqlite`, `node:http`, `node:net` tích hợp sẵn
@@ -372,6 +390,14 @@ npm run test:coverage # Với báo cáo vùng phủ (100% trên mọi chỉ số
372
 
373
  Xem [tests/README.md](tests/README.md) để biết tài liệu đầy đủ.
374
 
 
 
 
 
 
 
 
 
375
  ## Giấy phép
376
 
377
  [MIT](LICENSE) — Bản quyền (c) 2026 Dang Khoa <i.am@dangkhoa.dev>
 
1
+ # Nodejs JSON API Server
2
+
3
+ [![Nodejs 22.x](https://img.shields.io/badge/Nodejs-22.x-339933?style=flat&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
4
+ [![Nodejs 24.x](https://img.shields.io/badge/Nodejs-24.x-339933?style=flat&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
5
+ [![Nodejs 26.x](https://img.shields.io/badge/Nodejs-26.x-339933?style=flat&logo=nodedotjs&logoColor=white)](https://nodejs.org/)
6
+ [![CI](https://github.com/dangkhoa2016/NodeJs-JSON-API-Server/actions/workflows/test.yml/badge.svg)](https://github.com/dangkhoa2016/NodeJs-JSON-API-Server/actions/workflows/test.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
 
9
  > 🌐 Language / Ngôn ngữ: [English](README.md) | **Tiếng Việt**
10
 
11
  Một REST API tương thích JSONPlaceholder, được xây dựng chủ yếu bằng **Node.js built-ins** — dependency runtime duy nhất là `argon2` dùng để băm mật khẩu admin. Dùng `node:sqlite` để lưu trữ và một Redis client tự xây dựng trên giao thức RESP qua TCP sockets.
12
 
13
+ ## Điểm nổi bật
14
+
15
+ - **Zero-framework, dependency tối thiểu** — Chỉ **1 dependency production** (`argon2`). HTTP, SQLite, networking — tất cả đều dùng built-ins của Node.js. Không Express, không ORM, không Redis driver.
16
+ - **Redis client tự xây dựng** — Một Redis client hoàn chỉnh triển khai **giao thức RESP** qua TCP sockets. Hỗ trợ `AUTH`, `SELECT`, `EVAL` (Lua script), chuỗi kết nối URL, và tự động kết nối lại — tất cả trong ~200 dòng.
17
+ - **100% kiểm thử** — **250 bài kiểm thử trên 14 file** đạt 100% ở statements, branches, functions và lines. Kiểm thử tích hợp chạy với HTTP server thật + SQLite; kiểm thử đơn vị dùng dependency injection và CJS cache mocking.
18
+ - **Giới hạn tốc độ đa tầng** — Ba tầng fallback: Redis (Lua nguyên tử) → in-memory (LRU, 10k mục) → cho phép tất cả. Tích hợp circuit breaker (3 lỗi → mở 30s), trích xuất IP proxy dựa trên CIDR, và thời gian chặn tăng dần (5 ph → 20 ph → 1 giờ).
19
+ - **Docker tối ưu cho production** — Multi-stage build, **user không phải root**, tự động thiết lập DB khi khởi động, file `.env` bị loại trừ. Dotenv bị bỏ qua trong production — mọi cấu hình đều qua biến môi trường.
20
+ - **Cấu hình runtime** — Cập nhật cài đặt rate-limit và Redis qua admin API **mà không cần khởi động lại**. Thay đổi có hiệu lực ngay lập tức qua ghi đè trong bộ nhớ.
21
+ - **Bảo mật Argon2** — Mật khẩu admin được băm bằng argon2, kết quả được lưu cache với TTL 5 giây và LRU 1k mục. Ngăn chặn SQL injection qua danh sách trắng cột và thoát LIKE. Giới hạn kích thước body ở 1 MB.
22
+ - **Dev server với file watching tích hợp** — `npm run dev` dùng cờ `--watch` gốc của Node. Không cần Nodemon, chokidar, hay bất kỳ dependency thêm nào.
23
+ - **Tài liệu song ngữ** — Đầy đủ tài liệu bằng **tiếng Anh và tiếng Việt** cho README, hướng dẫn kiểm thử và kiến trúc kỹ thuật.
24
+
25
  ## Công nghệ sử dụng
26
 
27
  - **Node.js >= 22** — runtime với `node:sqlite`, `node:http`, `node:net` tích hợp sẵn
 
390
 
391
  Xem [tests/README.md](tests/README.md) để biết tài liệu đầy đủ.
392
 
393
+ ## Dự án tương tự
394
+
395
+ Nếu bạn thích server này nhưng muốn có **giao diện dashboard** được xây dựng bằng **Tailwind CSS**, hãy xem:
396
+
397
+ - **GitHub:** [JSON-API-Server-With-Dashboard-UI](https://github.com/dangkhoa2016/JSON-API-Server-With-Dashboard-UI)
398
+
399
+ Dự án cung cấp cùng API tương thích JSONPlaceholder nhưng kèm giao diện web trực quan — cũng rất hay!
400
+
401
  ## Giấy phép
402
 
403
  [MIT](LICENSE) — Bản quyền (c) 2026 Dang Khoa <i.am@dangkhoa.dev>