Files
16gagent/output/contract-mgmt/apps/api/README.md
T
2026-06-06 10:40:48 +08:00

2.7 KiB

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 — 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

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

clients

  • GET /api/clients — List all
  • GET /api/clients/:id — Get by ID
  • POST /api/clients — Create
  • PUT /api/clients/:id — Update
  • DELETE /api/clients/:id — Delete

templates

  • GET /api/templates — List all
  • GET /api/templates/:id — Get by ID
  • POST /api/templates — Create
  • PUT /api/templates/:id — Update
  • DELETE /api/templates/:id — Delete

System

  • GET /api/health — Health check