This is a simple Ecommerce website to sell wines. It's entirely built on Vanilla JavaScript.
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.
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()
.
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.
- Download the Project and initialize it with NODE JS.
- You will available a couple of endpoints to query. Their names are:
/categoria/:name
/all
/varietal/:name
/nombre/:name
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. */
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. */
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 */
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. */
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.
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:
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.