NoteApp — 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
items
GET /api/items— List allGET /api/items/:id— Get by IDPOST /api/items— CreatePUT /api/items/:id— UpdateDELETE /api/items/:id— Delete
stock_in
GET /api/stock_in— List allGET /api/stock_in/:id— Get by IDPOST /api/stock_in— CreatePUT /api/stock_in/:id— UpdateDELETE /api/stock_in/:id— Delete
stock_out
GET /api/stock_out— List allGET /api/stock_out/:id— Get by IDPOST /api/stock_out— CreatePUT /api/stock_out/:id— UpdateDELETE /api/stock_out/:id— Delete
stocktaking
GET /api/stocktaking— List allGET /api/stocktaking/:id— Get by IDPOST /api/stocktaking— CreatePUT /api/stocktaking/:id— UpdateDELETE /api/stocktaking/:id— Delete
stock_alerts
GET /api/stock_alerts— List allGET /api/stock_alerts/:id— Get by IDPOST /api/stock_alerts— CreatePUT /api/stock_alerts/:id— UpdateDELETE /api/stock_alerts/:id— Delete
warehouse
GET /api/warehouse— List allGET /api/warehouse/:id— Get by IDPOST /api/warehouse— CreatePUT /api/warehouse/:id— UpdateDELETE /api/warehouse/:id— Delete
System
GET /api/health— Health check