Giter VIP home page Giter VIP logo

winemmerce's Introduction

winemmerce

This is a simple Ecommerce website to sell wines. It's entirely built on Vanilla JavaScript.

wines.json

The file wines.json works as a sort of database with information about the wine labels. You can find information about the type of grape, category, time to maseration, name of label and a description about the flavor in mouth.

HTTP Methods

I just include GET method. POST, PUT, DELETE and PATCH are not necessary here. This is just a mockup for fill a sample. In the near future I'm thinking to add an option to POST new wines, writing a JSON file included in this project, using the JavaScript FileServer object().

images (folder)

This folder contains the images about every bottle, referenced on the imagen property in every object of the JSON file. The extension used in images is .webp. I am not serving images with the results of query. You can think the correct way to obtain it according to the results page. Maybe in the future I can pass the absolute URL to the image, but not for now.

How to use it

  1. Download the Project and initialize it with NODE JS.
  2. You will available a couple of endpoints to query. Their names are:
    • /categoria/:name
    • /all
    • /varietal/:name
    • /nombre/:name

Examples

/all

Calling the /all endpoint you will get the complete information about the wines available.

GET http://localhost:PORT/all 
/* You will get the complete list of wines. */

categoria/:name

You can check into the ** wines.js ** file the different categories available, calling the endpoint categoria and passing on it the category you are looking for. IE: /categoria/Blanco and you will get all the white wine labels. Also using /categoria/Tinto you'll get the Red wine labels, etcetera.

GET http://localhost:PORT/categoria/Blanco
/* You will get the complete list of white wines. */

varietal/:name

You can call the endpoint /varietal passing a parameter to get the kind of grape you want: Chardonnay, Malbec, Cabernet, Torrontes, etcetera. You don't need to specify a combined name for the varietal. IE: if you pass the Cabernet parameter and the list of wines will include both of them: cabernet sauvignon and cabernet franc. If you want only Cabernet Franc, specify just 'Franc' in the parameter or use the complete name Cabernet Franc including it as a parameter of the JavaScript encodeURIComponent() method.

GET http://localhost:PORT/varietal/Malbec 
/* You will get the complete list of Malbec grape wines. */

const param = encodeURIComponent('Cabernet Franc')
GET http://localhost:PORT/varietal/:param 
/* You will get the complete URL encoded to find a combined name on the wines database */

nombre/:name

You can call the endpoint /nombre passing a parameter to get a list of bottles filtered by part of their name: Trumpeter, Ruttini, etcetera. You don't need to specify a combined name. IE: if you pass the Reserve parameter and the list of wines will include all the name that includes Reserve as part of it. If you want to get an exact label, you can add a parameter as Rutini Rosé de Malbec, and you should including it into the JavaScript encodeURIComponent() method.

GET http://localhost:PORT/nombre/Ruttini 
/* You will get the complete list of wines labeled as Ruttini. */

Bubbles

The bubble wines are saved under the categoria Espumantes. In adition to they're grouped by the type of grape. You will get in the complete list of its category.

Testing the endpoints

If you are using Visual Studio Code as your primary code editor, you can integrate on it the Thunder Client Extension. It works the same way of POSTMAN and many other options for testing purposes. Check out the following image where you'll find how to use Thunder Client easily:

Testing the endpoint

More endpoints

If you are looking for a fine tuning of its API, you can suggest another type of endpoints you are looking for for your project and I will add it ASAP. Or better, you can modify this project creating all the options to find, you are considering on.

winemmerce's People

Contributors

mobilepadawan avatar

Stargazers

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