This is a simple Recipe Management API built with Node.js, Express, and TypeScript, interfacing with a MySQL database. It allows for basic CRUD operations on recipes.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
What things you need to install the software and how to install them:
- Node.js
- npm or yarn
- MySQL
A step-by-step series of examples that tell you how to get a development env running:
First, clone the repository to your local machine:
git clone https://your-repository-url-here.git
cd your-repository-name
yarn
DB_HOST=localhost DB_USER=your_mysql_username DB_PASSWORD=your_mysql_password DB_DATABASE=recipes_db
Copy the .env.sample file to a new file named .env and update the variables to match your local setup.
cp .env.sample .env
yarn start
The following endpoints are available:
GET /recipes
- Retrieve all recipes.GET /recipes/:id
- Retrieve a single recipe by its ID.POST /recipes
- Create a new recipe:
http://localhost:5000/api/recipes
{
"title": "Chocolate Cake",
"description": "Rich and moist chocolate cake with a silky chocolate ganache.",
"ingredients": [
{ "name": "all-purpose flour", "quantity": "200g" },
{ "name": "sugar", "quantity": "100g" },
{ "name": "cocoa powder", "quantity": "50g" }
]
}
PUT /recipes/:id
- Update an existing recipe.DELETE /recipes/:id
- Delete a recipe.GET /recipes/search
- Search for recipes by ingredients:
http://localhost:5000/api/recipes/search?ingredients=garlic,broccoli
yarn typeorm schema:drop
- Node.js - The JavaScript runtime environment.
- Express - Web framework for Node.js.
- TypeScript - Typed superset of JavaScript.
- MySQL - Open-source relational database management system.