Files
2026-06-06 10:40:48 +08:00

133 lines
3.2 KiB
Markdown

# TeamFlow — Backend API
> 一款支持多端同步、Markdown 编辑和标签管理的笔记应用。
## Tech Stack
- **Runtime**: Node.js
- **Framework**: Fastify 5
- **Language**: TypeScript
- **Database**: SQLite (better-sqlite3)
- **Auth**: JWT + bcrypt
## Getting Started
```bash
# 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` — Register
- `POST /api/auth/login` — Login
- `GET /api/auth/me` — Current user (auth required)
### Resources
#### users
- `GET /api/users` — List all
- `GET /api/users/:id` — Get by ID
- `POST /api/users` — Create
- `PUT /api/users/:id` — Update
- `DELETE /api/users/:id` — Delete
#### boards
- `GET /api/boards` — List all
- `GET /api/boards/:id` — Get by ID
- `POST /api/boards` — Create
- `PUT /api/boards/:id` — Update
- `DELETE /api/boards/:id` — Delete
#### tasks
- `GET /api/tasks` — List all
- `GET /api/tasks/:id` — Get by ID
- `POST /api/tasks` — Create
- `PUT /api/tasks/:id` — Update
- `DELETE /api/tasks/:id` — Delete
#### members
- `GET /api/members` — List all
- `GET /api/members/:id` — Get by ID
- `POST /api/members` — Create
- `PUT /api/members/:id` — Update
- `DELETE /api/members/:id` — Delete
#### items
- `GET /api/items` — List all
- `GET /api/items/:id` — Get by ID
- `POST /api/items` — Create
- `PUT /api/items/:id` — Update
- `DELETE /api/items/:id` — Delete
#### activity_logs
- `GET /api/activity_logs` — List all
- `GET /api/activity_logs/:id` — Get by ID
- `POST /api/activity_logs` — Create
- `PUT /api/activity_logs/:id` — Update
- `DELETE /api/activity_logs/:id` — Delete
#### stats
- `GET /api/stats` — List all
- `GET /api/stats/:id` — Get by ID
- `POST /api/stats` — Create
- `PUT /api/stats/:id` — Update
- `DELETE /api/stats/:id` — Delete
#### notes
- `GET /api/notes` — List all
- `GET /api/notes/:id` — Get by ID
- `POST /api/notes` — Create
- `PUT /api/notes/:id` — Update
- `DELETE /api/notes/:id` — Delete
#### tags
- `GET /api/tags` — List all
- `GET /api/tags/:id` — Get by ID
- `POST /api/tags` — Create
- `PUT /api/tags/:id` — Update
- `DELETE /api/tags/:id` — Delete
#### note_tags
- `GET /api/note_tags` — List all
- `GET /api/note_tags/:id` — Get by ID
- `POST /api/note_tags` — Create
- `PUT /api/note_tags/:id` — Update
- `DELETE /api/note_tags/:id` — Delete
### System
- `GET /api/health` — Health check