The App is implemented using Node.js and Express, with data sourced from third-party APIs for cocktails and beers.
- Getting Started
- API Endpoints
- Exercise 1
- Exercise 2 (Task A)
Before running the service, ensure you have the following installed:
- Node.js
- npm (Node Package Manager)
-
Clone the repository:
git clone <repository-url>
-
Install dependencies:
cd <repository-directory> npm install
-
Enviroment variables
- Generate API Key:
- Visit the API Ninjas website.
- Create an account if you don't have one.
- After creating an account, navigate to your profile.
- Find your API key, which will be available on this page.
- Create
.env
File:
- In the root directory of your project, create a file named
.env
. - Inside the
.env
file, add the API key in the format:API_KEY=your_api_key_here
.
-
Start the service:
npm start
-
Endpoint:
/beer
-
Method:
GET
-
Description: Returns details of a randomly selected beer.
-
Example Response:
{ "name": "Punk IPA", "tagline": "Post Modern Classic", "ABV": 5.6, "IBU": 41.5, "foodPairing": [ "Fresh Crab with Lemon", "Garlic Butter Dipping Sauce", "Goats Cheese Salad", "Creamy Lemon Bar doused in powdered sugar." ] }
-
Endpoint:
/cocktail
-
Method:
GET
-
Description: Returns details of a randomly selected cocktail.
-
Example Response:
{ "name": "Mojito", "tagline": "Classic Elegance", "ingredients": [ "1 1/2 oz Light rum", "2 tsp Sugar", "8 Fresh mint leaves", "1/2 Lime", "Soda water" ], "instructions": "Muddle mint leaves with sugar and lime juice. Add a splash of soda water and fill the glass with ice. Pour the rum and top with soda water. Garnish and serve with straw." }
-
Endpoint:
/suggestion
-
Method:
GET
-
Description: Returns a suggested drink based on the user's local time. It suggests a random beer during the day and a cocktail starting with the first letter of the user's first name during the night.
-
Example Response:
{ "name": "Punk IPA", "tagline": "Post Modern Classic", "ABV": 5.6, "IBU": 41.5, "foodPairing": [ "Fresh Crab with Lemon", "Garlic Butter Dipping Sauce", "Goats Cheese Salad", "Creamy Lemon Bar doused in powdered sugar." ] }