🎉 init: 小龙的工作空间
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
# ShopApp — 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
|
||||
#### products
|
||||
- `GET /api/products` — List all
|
||||
- `GET /api/products/:id` — Get by ID
|
||||
- `POST /api/products` — Create
|
||||
- `PUT /api/products/:id` — Update
|
||||
- `DELETE /api/products/:id` — Delete
|
||||
|
||||
#### orders
|
||||
- `GET /api/orders` — List all
|
||||
- `GET /api/orders/:id` — Get by ID
|
||||
- `POST /api/orders` — Create
|
||||
- `PUT /api/orders/:id` — Update
|
||||
- `DELETE /api/orders/:id` — Delete
|
||||
|
||||
#### stocktaking
|
||||
- `GET /api/stocktaking` — List all
|
||||
- `GET /api/stocktaking/:id` — Get by ID
|
||||
- `POST /api/stocktaking` — Create
|
||||
- `PUT /api/stocktaking/:id` — Update
|
||||
- `DELETE /api/stocktaking/:id` — Delete
|
||||
|
||||
#### suppliers
|
||||
- `GET /api/suppliers` — List all
|
||||
- `GET /api/suppliers/:id` — Get by ID
|
||||
- `POST /api/suppliers` — Create
|
||||
- `PUT /api/suppliers/:id` — Update
|
||||
- `DELETE /api/suppliers/:id` — Delete
|
||||
|
||||
#### stock_alerts
|
||||
- `GET /api/stock_alerts` — List all
|
||||
- `GET /api/stock_alerts/:id` — Get by ID
|
||||
- `POST /api/stock_alerts` — Create
|
||||
- `PUT /api/stock_alerts/:id` — Update
|
||||
- `DELETE /api/stock_alerts/:id` — Delete
|
||||
|
||||
### System
|
||||
- `GET /api/health` — Health check
|
||||
Reference in New Issue
Block a user