# SocialApp — Backend API > 一款以内容分享和用户互动为核心的社交应用。 ## 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 #### contracts - `GET /api/contracts` — List all - `GET /api/contracts/:id` — Get by ID - `POST /api/contracts` — Create - `PUT /api/contracts/:id` — Update - `DELETE /api/contracts/:id` — Delete #### approvals - `GET /api/approvals` — List all - `GET /api/approvals/:id` — Get by ID - `POST /api/approvals` — Create - `PUT /api/approvals/:id` — Update - `DELETE /api/approvals/:id` — Delete #### customers - `GET /api/customers` — List all - `GET /api/customers/:id` — Get by ID - `POST /api/customers` — Create - `PUT /api/customers/:id` — Update - `DELETE /api/customers/:id` — Delete #### reminders - `GET /api/reminders` — List all - `GET /api/reminders/:id` — Get by ID - `POST /api/reminders` — Create - `PUT /api/reminders/:id` — Update - `DELETE /api/reminders/:id` — Delete #### articles - `GET /api/articles` — List all - `GET /api/articles/:id` — Get by ID - `POST /api/articles` — Create - `PUT /api/articles/:id` — Update - `DELETE /api/articles/: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 #### comments - `GET /api/comments` — List all - `GET /api/comments/:id` — Get by ID - `POST /api/comments` — Create - `PUT /api/comments/:id` — Update - `DELETE /api/comments/:id` — Delete #### media - `GET /api/media` — List all - `GET /api/media/:id` — Get by ID - `POST /api/media` — Create - `PUT /api/media/:id` — Update - `DELETE /api/media/:id` — Delete ### System - `GET /api/health` — Health check