2.1 KiB
2.1 KiB
EduPlatform — 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
courses
GET /api/courses— List allGET /api/courses/:id— Get by IDPOST /api/courses— CreatePUT /api/courses/:id— UpdateDELETE /api/courses/:id— Delete
chapters
GET /api/chapters— List allGET /api/chapters/:id— Get by IDPOST /api/chapters— CreatePUT /api/chapters/:id— UpdateDELETE /api/chapters/:id— Delete
students
GET /api/students— List allGET /api/students/:id— Get by IDPOST /api/students— CreatePUT /api/students/:id— UpdateDELETE /api/students/:id— Delete
assignments
GET /api/assignments— List allGET /api/assignments/:id— Get by IDPOST /api/assignments— CreatePUT /api/assignments/:id— UpdateDELETE /api/assignments/:id— Delete
System
GET /api/health— Health check