OAFlow — Backend API
一款支持审批流、考勤管理、部门协作的企业办公自动化系统。
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
contracts
GET /api/contracts— List allGET /api/contracts/:id— Get by IDPOST /api/contracts— CreatePUT /api/contracts/:id— UpdateDELETE /api/contracts/:id— Delete
approvals
GET /api/approvals— List allGET /api/approvals/:id— Get by IDPOST /api/approvals— CreatePUT /api/approvals/:id— UpdateDELETE /api/approvals/:id— Delete
customers
GET /api/customers— List allGET /api/customers/:id— Get by IDPOST /api/customers— CreatePUT /api/customers/:id— UpdateDELETE /api/customers/:id— Delete
reminders
GET /api/reminders— List allGET /api/reminders/:id— Get by IDPOST /api/reminders— CreatePUT /api/reminders/:id— UpdateDELETE /api/reminders/:id— Delete
tickets
GET /api/tickets— List allGET /api/tickets/:id— Get by IDPOST /api/tickets— CreatePUT /api/tickets/:id— UpdateDELETE /api/tickets/:id— Delete
items
GET /api/items— List allGET /api/items/:id— Get by IDPOST /api/items— CreatePUT /api/items/:id— UpdateDELETE /api/items/:id— Delete
System
GET /api/health— Health check