/cooking-home-backend

Backend side of the Cooking Home application

Primary LanguageJavaScript

cooking-home-backend

Cooking Home offers users an extensive recipe search engine and recommends recipes based on their favorite foods and the ingredients they have at home.

cooking-home-backend repository contains the backend-side codebase of the Cooking Home application, serving as a serverless RESTful API.

Base API URL: https://mioqkb90kc.execute-api.ca-central-1.amazonaws.com/prod/api

github/cooking-home-frontend: https://github.com/kohdc1723/cooking-home-frontend


Tech stack

Built with

javascript-logo nodejs-logo express-logo mongodb-logo mongoose-logo jwt-logo

CI/CD with

aws-lambda-logo aws-api-gateway-logo github-actions-logo


File structure

.
├── index.js                      # entry point of the express app
│
├── routes                        # routes for distinct features
│   ├── rootRoutes.js             # root routes
│   ├── authRoutes.js             # routes related to the authentication
│   ├── preferenceRoutes.js       # routes related to the user preference
│   └── usersRoutes.js            # routes related to the users
│
├── models                        # Mongoose schemas
│   ├── Preference.js             # Preference schema
│   └── User.js                   # User schema
│
├── views                         # HTML templates for rendering views
│   ├── 404.html                  # HTML for the 404 error page
│   └── index.html                # HTML for the index page
│
├── controllers                   # controllers for handling business logic
│   ├── authController.js         # controllers related to the authentication
│   ├── preferenceController.js   # controllers related to the user preference
│   └── usersController.js        # controllers related to the users
│
├── middlewares                   # custom middlewares
│   └── verifyToken.js            # middleware for verifying JWT
│
├── config                        # configurations
│   ├── allowedOrigins.js         # allowed origins for CORS
│   ├── corsOptions.js            # configuration for CORS
│   └── connectDb.js              # configuration for connecting to MongoDB
│
├── public                        # static files
│   └── css                       # stylesheets
│       └── style.css             # main css file
│
└── README.md                     # README file

Endpoints

Authentication

Method Endpoint Parameters (required*) Description Auth Required
POST /auth/login username: string*
password: string*
Logs in a user No
GET /auth/refresh - Refreshes the access token using refresh token Refresh Token
POST /auth/logout - Logs out the user No

Users

Method Endpoint Parameters (required*) Description Auth Required
GET /users/:id - Get a user by id Access Token
POST /users username: string*
password: string*
Create a new user No
PATCH /users id: string*
username: string*
password: string
Update a user Access Token
DELETE /users id: string* Delete a user Access Token

Preference

Method Endpoint Parameters (required*) Description Auth Required
GET /preference/:userId - Get a preference by user id Access Token
POST /preference userId: string* Create a default preference of the user Access Token
PATCH /preference id: string*
favorites: [string]*
ingredients: [string]*
Update a preference Access Token