# PetCare — 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 #### 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 #### pets - `GET /api/pets` — List all - `GET /api/pets/:id` — Get by ID - `POST /api/pets` — Create - `PUT /api/pets/:id` — Update - `DELETE /api/pets/:id` — Delete #### schedules - `GET /api/schedules` — List all - `GET /api/schedules/:id` — Get by ID - `POST /api/schedules` — Create - `PUT /api/schedules/:id` — Update - `DELETE /api/schedules/:id` — Delete #### daily_logs - `GET /api/daily_logs` — List all - `GET /api/daily_logs/:id` — Get by ID - `POST /api/daily_logs` — Create - `PUT /api/daily_logs/:id` — Update - `DELETE /api/daily_logs/:id` — Delete ### System - `GET /api/health` — Health check