Node.js RESTful API project for managing educational resources in an academy. It offers full CRUD functionality for users , courses , bootcamps and reviews with Express.js for routing and MongoDB for storage.
Below is an overview of the available endpoints and their functionalities.
- To explore the Swagger UI schema and view available endpoints, navigate to
http://localhost:3000/api-docs
after running the server. - You can also test these endpoints via this Postman collection
This project implements the following key features to ensure a robust, secure, and scalable web application:
JWT-Based Authentication:
Secure user authentication using JSON Web Tokens (JWT) to manage user sessions.Password Hashing
: Secure password storage with hashing using thebcryptjs
package.Role-Based Access Control (RBAC)
: Authorization system to manage access based on user roles, ensuring secure data handling.Password Recovery
: Full password recovery system, including both "reset password" and "forgot password" functionalities.Email Notifications
: Automated email notifications for password recovery using thenodemailer
package.Server-Side Validation
: Input validation using theexpress-validator
package to ensure data integrity and security.Advanced MongoDB Queries
: Efficient data retrieval and manipulation using the MongoDB Aggregation Framework.Pagination
: Implemented pagination for efficient result retrieval in larger datasets.Image Upload
: Secure image uploading functionality using theexpress-fileupload
package.SEO-Friendly URLs
: Convert text into URL-friendly slugs using theslugify
package.Rate Limiting
: Protect the application from abuse by implementing rate limiting using theexpress-rate-limit
package.Mongoose Hooks
: Utilized Mongoosepre
andpost
hooks for automating tasks such as data validation and modifications before saving or retrieving documents.
- Clone the repository
git clone https://github.com/carpodok/dev-academy-rest-api.git
- Navigate to the project directory:
cd dev-academy-rest-api
- Install required dependencies
npm install
- Creat a
.env
file on the root of the project and add the following environment variables. To set up email host informations visit Mailtrap and create your account.
NODE_ENV=development
PORT=3000
MONGO_URI=<your-mongo-uri>
FILE_UPLOAD_PATH= ./public/uploads
MAX_FILE_UPLOAD=1000000
JWT_SECRET=<your-jwt-secret>
JWT_EXPIRE=30d
JWT_COOKIE_EXPIRE=30
// Set up with your own configurations
SMTP_HOST=sandbox.smtp.mailtrap.io
SMTP_PORT=
SMTP_EMAIL=
SMTP_PASSWORD=
FROM_EMAIL=noreply@devacademy.io
FROM_NAME=Dev Academy
- To seed the database with users, bootcamps, courses and reviews with data from the "_data" folder, run
# Destroy all data
node seeder -d
# Import all data
node seeder -i
- To start the server, run the following command on the root of the project path;
npm start
For the development purpose;
npm run dev
- The application will be running on
http://localhost:3000
Contributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.
This project is licensed under the MIT License.