MyProject — 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
boards
GET /api/boards— List allGET /api/boards/:id— Get by IDPOST /api/boards— CreatePUT /api/boards/:id— UpdateDELETE /api/boards/:id— Delete
tasks
GET /api/tasks— List allGET /api/tasks/:id— Get by IDPOST /api/tasks— CreatePUT /api/tasks/:id— UpdateDELETE /api/tasks/: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