Giter VIP home page Giter VIP logo

food-ordering-app-server's Introduction

Food Delivery Proxy Server

This Node.js application sets up a proxy server using Express that fetches data from a third-party (Swiggy) API and exposes it to a client (Food ordering app).

  1. List all restaurants for the given location (lat & lng)
  • lat (required) : latitude of the location to search for restaurants

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

  • Exapmple request : https://food-ordering-app-server.vercel.app/api/proxy/swiggy/dapi/restaurants/list/v5?lat=18.5204303&lng=73.8567437&&is-seo-homepage-enabled=true&page_type=DESKTOP_WEB_LISTING

  • 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

  • Access the home page by navigating to http://localhost:3000 in your web browser.

  • Utilize the Swiggy API proxy by sending requests to http://localhost:3000/api/proxy/swiggy/dapi, which will be forwarded to Swiggy's API endpoint.

  • Example :

const response = await fetch(
    "https://food-ordering-app-server.vercel.app/api/proxy/swiggy/dapi/restaurants/list/v5?lat=18.5204303&lng=73.8567437&&is-seo-homepage-enabled=true&page_type=DESKTOP_WEB_LISTING"
);
const data = await response.json();
  1. List all menu items for the given restaurant Id (restaurantId)
  • restaurantId (required): ID of the restaurant's menu.

  • Example Request : https://food-ordering-app-server.vercel.app/api/proxy/swiggy/dapi/menu/pl?page-type=REGULAR_MENU&complete-menu=true&lat=18.5204303&lng=73.8567437&restaurantId={restaurantId}

  • 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://food-ordering-app-server.vercel.app/api/proxy/swiggy/dapi/menu/pl?page-type=REGULAR_MENU&complete-menu=true&lat=18.5204303&lng=73.8567437&restaurantId={restaurantId}`);

Example :

const response = await fetch(
    "https://food-ordering-app-server.vercel.app/api/proxy/swiggy/dapi/menu/pl?page-type=REGULAR_MENU&complete-menu=true&lat=18.5204303&lng=73.8567437&restaurantId={restaurantId}"
);
const data = await response.json();

Dependencies

express: Web application framework for Node.js http-proxy-middleware: HTTP middleware for Node.js to enable proxying requests cors: Cross-Origin Resource Sharing middleware for Node.js

Features

  • Proxy Middleware: Routes requests to /api/proxy/swiggy/dapi to the Swiggy API, enabling seamless integration with Swiggy's services.
  • CORS Configuration: Implements CORS headers to allow cross-origin requests, enabling communication with the server from any origin.
  • Home Page: Displays a welcoming message for food lovers on the home page.

Setup

  1. Clone the 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/onkar895/FOOD-ORDERING-APP-SERVER.git"

Install dependencies

  npm install

Start the server

  npm start

The server will be running at http://localhost:3000 by default, or at the port specified by the PORT environment variable.

Deploy your own server

Note : Push your code into your Github Repostory

  1. Create an account in "https://render.com/ or https://vercel.com/" using Github.
  2. Click on New + and select web services on render and Add new and then Project on vercel
  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.

food-ordering-app-server's People

Contributors

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