Skip to content

IITI-tushar/blog-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal Blogging Platform API

This is a simple RESTful API for a personal blogging platform built using Express.js and MongoDB. The API allows users to perform CRUD operations on blog posts.

Features

  • Create a new blog post
  • Read a single blog post or all blog posts
  • Update an existing blog post
  • Delete an existing blog post
  • Filter blog posts by a search term

Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose

Getting Started

Prerequisites

  • Node.js installed on your machine
  • MongoDB installed or access to a MongoDB database

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/blog-api.git
    
  2. Navigate to the project directory:

    cd blog-api
    
  3. Install the dependencies:

    npm install
    

Configuration

  1. Set up your MongoDB connection in src/config/database.js.
  2. Update any necessary environment variables.

Running the Application

To start the server, run:

npm start

The server will run on http://localhost:3000.

API Endpoints

Create a Blog Post

  • POST /api/posts
  • Request Body: { "title": "Post Title", "content": "Post Content", "author": "Author Name" }

Get a Single Blog Post

  • GET /api/posts/:id

Get All Blog Posts

  • GET /api/posts

Update a Blog Post

  • PUT /api/posts/:id
  • Request Body: { "title": "Updated Title", "content": "Updated Content" }

Delete a Blog Post

  • DELETE /api/posts/:id

Search Blog Posts

  • GET /api/posts/search?term=searchTerm

Error Handling

The API includes error handling middleware to manage errors and send appropriate HTTP responses.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published