This documentation provides an overview of the Web Service and RESTful API implemented our website Eduliterate, built using
Eduliterate is a web application built with Node.js and MongoDB that facilitates book, user authentication, and subscription-based access to books. The application includes various endpoints for user registration, authentication, book management, and payment processing.
a. Prerequisites
- Node.js installed
- MongoDB Atlas account for database (update the .env file with your MongoDB connection URL)
- Set up environment variables in a
.envfile - Cloudinary to store image
b. Installation
- Clone the repository to your local machine:
https://github.com/FS-30/03-BE-Eduliterate-Express.git
- Open the project directory
cd 03-BE-Eduliterate-Express
npm install
- Set Environment Variables
DB_URL=mongodb+srv://your_username:your_password@your_mongodb_url/Eduliterate
JWT_SECRET=YourJWTSecretKey
CLOUDINARY_CLOUD_NAME=YourCloudinaryCloudName
CLOUDINARY_API_KEY=YourCloudinaryAPIKey
CLOUDINARY_API_SECRET=YourCloudinaryAPISecret
- Run it
npm start
The server will be running on http://localhost:3000
The project follows a modular structure:
index.js: Entry point of the application, establishes server connection and defines middleware.config/: Contains database configuration.middlewares/: Holds authentication middleware for authorization checks.models/: Contains Mongoose models for users, books, and payments.routes/: Includes routes for authentication and data handling.
Authentication
POST /auth/register: Register a new user.POST /auth/login: Log in an existing user.
Data Handling
a. Users
POST /data/users: Create a new user (admin-only).GET /data/users: Get all users (admin-only).PUT /data/users/:id: Update a user by ID (admin-only).DELETE /data/users/:id: Delete a user by ID (admin-only).
b. Books
POST /data/books: Create a new book (admin-only).GET /data/books: Get all books (accessible to all users).GET /data/books/:id: Get details of a book by ID.PUT /data/books/:id: Update a book by ID (admin-only).DELETE /data/books/:id: Delete a book by ID (admin-only).
c. Payments
POST /data/payment/upload: Upload payment image.
Postman Documentation Available here: https://documenter.getpostman.com/view/31106938/2s9YeG5Asr

