This project is a Course Management System built using TypeScript and Node.js. It contains RESTful API for managing courses. The system handles course data management and persist data in JSON files instead of a traditional database. It includes features such as validation, error handling, logging, and API documentation with Swagger.
- Getting Started
- API Documentation
- Project Structure
- Available Scripts
- Endpoints
- Data Models
- Testing
- Error Handling
- Logging
- Node.js (>= 14.x)
- npm (>= 6.x) or yarn
-
Clone the repository:
git clone https://github.com/aishacodes/CMS.git
-
Navigate to the project directory:
cd CMS
-
Install dependencies:
Using npm:
npm install
Or using yarn:
yarn
-
Run the application:
Start the development server:
Using npm:
npm run dev
Or using yarn:
yarn dev
-
Access the API:
The API will run at
http://localhost:3001/api
.
The project uses Swagger to generate API documentation. Once the server is running, you can access the API docs at:
http://localhost:3001/api-docs
├── controllers/ # Contains logics for handling API requests
├── data/ # Directory for storing JSON files(courses.json, modules.json, and lessons.json)
├── middlewares/ # Custom middleware for validation,swagger config, logging, error handling,
├── routes/ # API route definitions and swagger docs
├── types/ # TypeScript types definitions
├── utils/ # Utility functions
├── validators/ # Schemas
├── README.md # Project documentation
├── tsconfig.json # TypeScript configuration
└── package.json # Project metadata and dependencies
Here are some useful scripts for managing and running the project.
-
Running the development server:
Using npm:
npm run dev
Or using yarn:
yarn dev
-
Running tests:
Using npm:
npm test
Or using yarn:
yarn test
GET /courses
— Get all courses.GET /courses/{id}
— Get a specific course by ID.POST /courses
— Create a new course.PATCH /courses/{id}
— Update an existing course.DELETE /courses/{id}
— Delete a course by ID.
GET /modules
— Get all modules.GET /modules/{id}
— Get a specific module by ID.POST /modules
— Create a new module.PATCH /modules/{id}
— Update an existing module.DELETE /modules/{id}
— Delete a module by ID.
GET /lessons
— Get all lessons.GET /lessons/{id}
— Get a specific lesson by ID.POST /lessons
— Create a new lesson.PATCH /lessons/{id}
— Update an existing lesson.DELETE /lessons/{id}
— Delete a lesson by ID.
The project includes unit and integration tests using Jest and supatest.
Running tests:
Using npm:
npm test
Or using yarn:
yarn test