This is the backend API for a personal blog built using Node.js and Express.js, with MongoDB Atlas as the database. The API includes JWT-based authentication and role-based authorization, supporting three roles: Admin, Moderator, and User.
Hosted on Render: Blogging Platform API
Unauthenticated Users:
Authenticated Users:
For detailed information about the public API endpoints, please refer to the API Documentation.
Clone the repository:
git clone https://github.com/AbdallahRdf/blogging-platform-api.git
Install dependencies:
cd blogging-platform-api
npm install
Create a .env
file with the necessary environment variables:
PORT=Server_port_number.
JWT_SECRET_KEY=Secret_key_for_JWT_authentication.
MONGODB_CONNECTION_STRING=your-mongodb-connection-string
FRONTEND_URL=URL_of_your_frontend_application_(optional)
EMAIL_USER=Email_address_for_sending_emails
EMAIL_APP_PASSWORD=Application_password_for_the_email_account.
NODE_ENV=development_or_production
Create an initial admin user:
run the command below to run createAdmin.js script to create an admin user.
npm run create-admin
Start the development server:
npm run start:dev
If you want to contribute to this project, feel free to fork the repo and submit a pull request.