Code Monkey home page Code Monkey logo

instafood-server's Introduction

Instafood Web Server

A simple node.js web server that fetches data from a third-party (Swiggy) API and exposes it to a client (instafood) app.

Table of contents:

API Endpoints

  1. List all restaurants for the given location (lat & lng)
  • API Endpoint: /api/restaurants

  • HTTP Method: GET

  • Query Parameters:

    lat (required) : latitude of the location to search for restaurants

    lng (required) : longitude of the location to search for restaurants

  • Response Format: JSON

  • URL: https://instafood.onrender.com/api/restaurants?lat=:latquery&lng=:lngquery

  • Example Request:

    https://instafood.onrender.com/api/restaurants?lat=12.9351929&lng=77.62448069999999

  • Explanation : This API fetches the restaurant data for the given location from Swiggy API and exposes it to the clients. The response format of this API is same as Swiggy API enpoint.

  • Usage : In react app , you can hit this API like mentioned below

fetch(`https://instafood.onrender.com/api/restaurants?lat=${latitude}&lng=${longitude}`)

Example :

const response =  await fetch("https://instafood.onrender.com/api/restaurants?lat=12.9351929&lng=77.62448069999999")

const data = await response.json();
  1. List all menu items for the given restaurant Id (menuId)
  • API Endpoint: /api/menu

  • HTTP Method: GET

  • Query Parameters:

    lat (required) : latitude of the location to search for restaurants.

    lng(required) : longitude of the location to search for restaurants.

    menuId (required): ID of the restaurant's menu.

  • Response Format: JSON

  • URL: https://instafood.onrender.com/api/restaurants?lat=:latquery&lng=:lngquery&menuId=:menuId

  • Example Request:

    https://instafood.onrender.com/api/menu?lat=12.9351929&lng=77.62448069999999&menuId=113657

  • Explanation : This API fetches the restaurant data in json format for the given location from Swiggy API and exposes it to the clients. The response format of this API is same as Swiggy API enpoint.

  • Usage : In react app , you can hit this API like mentioned below

fetch(`https://instafood.onrender.com/api/restaurants?lat=${latitude}&lng=${longitude}&menuId=${menuId}`)

Example :

const response =  await fetch("https://instafood.onrender.com/api/menu?lat=12.9351929&lng=77.62448069999999&menuId=113657")

const data = await response.json();

Clone Repository

You need to write the following commands on the terminal screen (in vscode) so that you can run this project locally.

  git clone "https://github.com/HarshithaSolai/instafood-server.git"

Go to the project directory

  cd instafood-server

Install dependencies

  npm install

Start the server

  npm start

This server should now be running on localhost.

Deploy your own server

Note : Push your code into your Github Repostory

  1. Create an account in "https://render.com/" using Github
  2. Click on New + and select web services
  3. Connect to the repository ( node server) which you want to deploy
  4. Now, your server will be deployed in few minutes and a url to access your server will be provided.

Contribute to this repository

If you have any suggestions to improve this node server, please feel free to raise a PR.

Happy Coding !!!

instafood-server's People

Contributors

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