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
customers
GET /api/customers— List allGET /api/customers/:id— Get by IDPOST /api/customers— CreatePUT /api/customers/:id— UpdateDELETE /api/customers/:id— Delete
sales_pipeline
GET /api/sales_pipeline— List allGET /api/sales_pipeline/:id— Get by IDPOST /api/sales_pipeline— CreatePUT /api/sales_pipeline/:id— UpdateDELETE /api/sales_pipeline/:id— Delete
follow_ups
GET /api/follow_ups— List allGET /api/follow_ups/:id— Get by IDPOST /api/follow_ups— CreatePUT /api/follow_ups/:id— UpdateDELETE /api/follow_ups/:id— Delete
dashboard
GET /api/dashboard— List allGET /api/dashboard/:id— Get by IDPOST /api/dashboard— CreatePUT /api/dashboard/:id— UpdateDELETE /api/dashboard/:id— Delete
System
GET /api/health— Health check