2.0 KiB
2.0 KiB
BookShelf — Backend API
一款支持多端同步、Markdown 编辑和标签管理的笔记应用。
Tech Stack
- Runtime: Node.js
- Framework: Fastify 5
- Language: TypeScript
- Database: SQLite (better-sqlite3)
- Auth: JWT + bcrypt
Getting Started
# Install dependencies
npm install
# Development (hot reload)
npm run dev
# Build
npm run build
# Production start
npm run start
# Run tests
npm test
Project Structure
src/
├── index.ts # Server entry point
├── db/
│ ├── schema.ts # SQLite schema
│ └── client.ts # Database client
├── routes/
│ ├── auth.ts # Auth routes (register/login/me)
│ └── *.ts # CRUD routes
├── services/
│ └── *.ts # Business logic
├── middleware/
│ └── auth.ts # JWT middleware
├── types/
│ └── index.ts # TypeScript types
└── __tests__/
└── *.test.ts # Tests
API Endpoints
Auth
POST /api/auth/register— RegisterPOST /api/auth/login— LoginGET /api/auth/me— Current user (auth required)
Resources
users
GET /api/users— List allGET /api/users/:id— Get by IDPOST /api/users— CreatePUT /api/users/:id— UpdateDELETE /api/users/:id— Delete
notes
GET /api/notes— List allGET /api/notes/:id— Get by IDPOST /api/notes— CreatePUT /api/notes/:id— UpdateDELETE /api/notes/:id— Delete
tags
GET /api/tags— List allGET /api/tags/:id— Get by IDPOST /api/tags— CreatePUT /api/tags/:id— UpdateDELETE /api/tags/:id— Delete
note_tags
GET /api/note_tags— List allGET /api/note_tags/:id— Get by IDPOST /api/note_tags— CreatePUT /api/note_tags/:id— UpdateDELETE /api/note_tags/:id— Delete
System
GET /api/health— Health check