This project is a RESTful API for a Web Blog application built using Node.js. It provides a set of endpoints to manage users, posts, and comments. The API supports essential blog functionalities such as user authentication, creating and managing posts, and interacting with comments.
Below is an overview of the available endpoints and their functionalities.
- To view the Swagger UI schema, navigate to
http://localhost:3000/api-docs
in your browser after running the server. - You can test these endpoints via this Postman collection
- Node.js: Backend runtime environment.
- express.js: Web framework for Node.js.
- MongoDB: NoSQL database for storing user data.
- mongoose: ODM for MongoDB.
- express-validator: Server side validation for input fields
- bcrypt: Library for hashing passwords.
- JSON Web Tokens (JWT): Standard for creating secure access tokens.
- swagger-ui-express: Middleware to serve auto-generated Swagger API documentation in Express.js applications.
- swagger-jsdoc: Library to generate Swagger API documentation from JSDoc comments in your code.
- jest: Comprehensive testing of API endpoints using jest for unit tests and supertest for testing HTTP requests, ensuring reliable and consistent API functionality.
- Clone the repository
git clone https://github.com/carpodok/node-blog-app.git
- Navigate to the project directory:
cd node-blog-app
- Install required dependencies
npm install
- Creat a
.env
file on the root of the project and add the following environment variables
PORT=3000
MONGODB_URL=your_mongodb_uri
JWT_SECRET=your_jwt_secret
- 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
You can also run this application using Docker
-
Ensure Docker and Docker Compose are installed. If not, follow the official Docker installation guide.
-
Build and run the applicaiton with Docker Compose:
docker-compose up
The application will be accessible at
http://localhost:3000
-
Using a custom
.env
file: Ensure you have a.env
file with the required environment variables (PORT
,MONGODB_URL
,JWT_SECRET
), as it will be loaded automatically.
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.