Skip to content

carpodok/node-blog-app

Repository files navigation

Web Blog API

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.

Endpoints

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
Screenshot 2024-08-31 at 00 08 18

Technologies Used

  • 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.

Installation

  1. Clone the repository
  git clone https://github.com/carpodok/node-blog-app.git
  1. Navigate to the project directory:
 cd node-blog-app
  1. Install required dependencies
 npm install

Configuration

  1. 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

Running the Application

  1. To start the server, run the following command on the root of the project path;
npm start

For the development purpose;

npm run dev
  1. The application will be running on http://localhost:3000

Running the Application with Docker

You can also run this application using Docker

  1. Ensure Docker and Docker Compose are installed. If not, follow the official Docker installation guide.

  2. Build and run the applicaiton with Docker Compose:

    docker-compose up

    The application will be accessible at http://localhost:3000

  3. 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.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.

License

This project is licensed under the MIT License.

Releases

No releases published

Packages

No packages published