Git Product home page Git Product logo

image-upload-posts-filter-sorting-in-nodejs's Introduction

Node.js REST API Project

Table of Contents

Getting Started

Follow these instructions to set up and run the project

Installation

  1. Clone the Repository:

    Clone the project repository:

    git clone https://github.com/shaarifg/image-upload-posts-filter-sorting-in-nodejs.git
  2. To run the code:

   npm install
   npm start

Libraries Used

Library Description
cloudinary Used for image upload on clound to get public url. Cloudinary is a cloud-based solution for storing data.
dotenv Used for managing environment variables.
express Used for building the rest APIs.
express-fileupload Used for handling file uploads. Express File Upload is a middleware for handling file uploads in Express applications.
joi Used for request data validation.
mongoose Used for interacting with MongoDB. Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js.
nodemon Used for automatic server restarts during development.

API Documentation

Here are the available API endpoints with their descriptions, request methods, example API usage, and response descriptions.

Endpoint Description Request Method Example API Response Description
/ Home route GET / Returns a greeting message.
/posts Create a new post and save it to the database POST http://localhost:8080/posts Creates a new post and returns the saved post.
/posts Get all the posts GET http://localhost:8080/posts Returns a list of all posts.
/search/posts Search posts by title and description GET http://localhost:8080/search/posts?search Searches for posts matching the search keyword.
/upload Upload an image POST /upload Uploads an image and returns the image URL.
/tags/posts Filter posts by tags GET http://localhost:8080/tags/posts Filters and returns posts based on specified tags. Need to provide json body object

Home Route

  • Endpoint: /
  • Description: This is the home route, which provides a simple greeting message.
  • Request Method: GET
  • Example API: GET /
  • Response Description: Returns a greeting message.

Create a Post

  • Endpoint: /posts
  • Description: Create a new post and save it to the database.
  • Request Method: POST
  • Example API: POST /posts
  • Response Description: Creates a new post and returns the saved post.

Get All Posts also support filter queries

  • Endpoint: /posts
  • Description: Get all the posts stored in the database.
  • Request Method: GET
  • Example API: GET /posts
  • Response Description: Returns a list of all posts.

Search Posts

  • Endpoint: /search/posts
  • Description: Search for posts using keywords found in the title and description.
  • Request Method: GET
  • Example API: GET /search/posts?search=keyword
  • Response Description: Searches for posts matching the query keyword.

Get All Posts filtered with provided tags

  • Endpoint: tags/posts
  • Description: Get all the posts stored in the database.
  • Request Method: GET
  • Example API: GET /tags/posts
  • json body Object:{ "tags":[] }
  • Response Description: Returns a list of all posts with specified tags.

Upload Image

  • Endpoint: /upload
  • Description: Upload an image to the server or cloud storage (e.g., Cloudinary).
  • Request Method: POST
  • Example API: POST /upload
  • Response Description: Uploads an image and returns the uploded image data with public url.

image-upload-posts-filter-sorting-in-nodejs's People

Contributors

shaarifg avatar sharif-iota avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.