Lunch and Learn is a Rails-based API that allows users to register, authenticate, and manage their favorite recipes. The API provides endpoints for user registration, user sessions, and managing favorites.
- Expose an API that aggregates data from multiple external APIs
- Expose an API that requires an authentication token
- Implement Basic Authentication
- Expose an API for CRUD functionality
- Determine completion criteria based on the needs of other developers
- Test both API consumption and exposure, making use of at least one mocking tool (VCR, Webmock, etc).
Ensure you have the following installed:
- Ruby (version 3.2.2+)
- Rails (version 7.0+)
- PostgreSQL
git clone https://github.com/Steddy1Love/lunch_and_learn.git
cd lunch_and_learn
bundle install
Set Up the Database
rails db:create
rails db:migrate
This project may require external API keys. You can obtain them from:
Create a .env file in the root directory and add your API keys:
GEOAPIFY_API_KEY=your_geoapify_api_key
OTHER_API_KEYS=your_other_api_key
rails server
Your API should now be running on http://localhost:3000.
Request:
POST /api/v1/users
Content-Type: application/json
Accept: application/json
{
"name": "Odell",
"email": "[email protected]",
"password": "treats4lyf",
"password_confirmation": "treats4lyf"
}
Response:
{
"data": {
"id": "1",
"type": "user",
"attributes": {
"name": "Odell",
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
Request:
POST /api/v1/sessions
Content-Type: application/json
Accept: application/json
{
"email": "[email protected]",
"password": "treats4lyf"
}
Response:
{
"data": {
"id": "1",
"type": "user",
"attributes": {
"name": "Odell",
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
Request:
POST /api/v1/favorites
Content-Type: application/json
Accept: application/json
{
"api_key": "jgn983hy48thw9begh98h4539h4",
"country": "thailand",
"recipe_link": "https://www.tastingtable.com/.....",
"recipe_title": "Crab Fried Rice (Khaao Pad Bpu)"
}
Response:
{
"success": "Favorite added successfully"
}
Request:
GET /api/v1/favorites?api_key=jgn983hy48thw9begh98h4539h4
Content-Type: application/json
Accept: application/json
Response:
{
"data": [
{
"id": "1",
"type": "favorite",
"attributes": {
"recipe_title": "Recipe: Egyptian Tomato Soup",
"recipe_link": "http://www.thekitchn.com/recipe-egyptian-tomato-soup-weeknight....",
"country": "egypt",
"created_at": "2022-11-02T02:17:54.111Z"
}
},
{
"id": "2",
"type": "favorite",
"attributes": {
"recipe_title": "Crab Fried Rice (Khaao Pad Bpu)",
"recipe_link": "https://www.tastingtable.com/.....",
"country": "thailand",
"created_at": "2022-11-07T03:44:08.917Z"
}
}
]
}
Run the tests with:
bundle exec rspec
Ensure all tests are passing before deploying or merging new code.
Contributions are welcome! Please open a pull request with your changes or create an issue to discuss any potential changes.