# OAFlow — 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 #### employees - `GET /api/employees` — List all - `GET /api/employees/:id` — Get by ID - `POST /api/employees` — Create - `PUT /api/employees/:id` — Update - `DELETE /api/employees/:id` — Delete #### attendance - `GET /api/attendance` — List all - `GET /api/attendance/:id` — Get by ID - `POST /api/attendance` — Create - `PUT /api/attendance/:id` — Update - `DELETE /api/attendance/: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 #### performance - `GET /api/performance` — List all - `GET /api/performance/:id` — Get by ID - `POST /api/performance` — Create - `PUT /api/performance/:id` — Update - `DELETE /api/performance/:id` — Delete ### System - `GET /api/health` — Health check