A simple Node.js API for managing recipes, using better-sqlite3 and SQLite as the database. Built with Express and TypeScript.
- Create, read, update, and delete recipes
- Input validation with celebrate and Joi
- Uses SQLite for lightweight, file-based or in-memory storage
- Dockerized for easy deployment
-
Clone the repository:
git clone https://github.com/benkwash/givery-recipe-api.git cd givery-recipe-api -
Install dependencies:
npm install
-
Create a
.envfile in the project root with the following content:PORT=3000 NODE_ENV=developmentNODE_SERVER_PORT: The port your server will run on (default: 3000)NODE_ENV: The environment mode (development,production, etc.)
-
Build the project (if using TypeScript):
npm run build
-
Start the server:
npm start
The API will be available at
http://localhost:3000.
npm run dev| Method | Endpoint | Description |
|---|---|---|
| GET | /recipes |
List all recipes |
| GET | /recipes/:id |
Get a recipe by ID |
| POST | /recipes |
Create a new recipe |
| PATCH | /recipes/:id |
Update a recipe by ID |
| DELETE | /recipes/:id |
Delete a recipe by ID |
{
"title": "Chicken Curry",
"making_time": "45 min",
"serves": "4 people",
"ingredients": "Chicken, Curry Powder, Onion, Garlic",
"cost": 1200
}-
Build the Docker image:
docker build -t recipe-api . -
Run the container:
docker run -p 3000:3000 --env-file .env recipe-api