This is the back end part of a simple Recipe MERN App.
This is a basic CRUD API. I used express-generator to start with a basic structure, MongoDB Compass for database management,
GET '/recipes/'
POST '/recipes/' (auth)
{
name, ingredients, instructions, tags, image, link;
}
GET '/recipes/:id'
DELETE '/recipes/:id'
PUT '/recipes/:id'
{
name, ingredients, instructions, tags, image, link;
}
(all auth)
GET '/users/'
GET '/users/fav'
PUT '/users/fav'
PUT '/users/addfav'
{
recipeId;
}
PUT '/users/removefav'
{
recipeId;
}
PUT '/users/update'
{
name, email;
}
PUT '/users/updatepassword'
{
password, newPassword;
}
POST '/auth/signup'
{
name, email, password;
}
POST '/auth/login'
{
name, password;
}
GET '/auth/logout'
POST '/auth/forgotpassword'
{
email;
}
PUT '/auth/resetpassword/:resettoken'
{
password;
}
I used express-generator to start with a basic structure, MongoDB Compass for database management,
MongoDB, Express and NodeJs
"@sendgrid/mail": email service,
"bcryptjs": hashing passwords,
"config": for configuration files,
"dotenv": for environment variables,
"express-validator": middleware for easy validate,
"helmet": security,
"html-to-text": for email service,
"jsonwebtoken": jwt,
"mongoose": Mongodb database connection,
"morgan": logger,
"pug": used for email format,
"slugify": slug links (not used)
you can download the repo to your computer with the command below
git clone https://github.com/voldev8/recipes-api
NodeJs installation
Create an .env file in root folder
MongoDB
MONGO_URI='your mongo uri'
Choose a port
PORT=
Token Settings
JWT_SECRET='secret for hashing'
JWT_COOKIE_EXPIRE=
JWT_EXPIRE=
Sendgrid installation and create an account
SENDGRID_API_KEY=
for the email
FROM_EMAIL=
FROM_NAME=
now install npm
$ npm install
starting the app
$ npm run start
for nodemon
$ npm run dev
Instead of starting the front end and back end separately, concurrently npm can be used More info
MIT ©2020 Volkan Uyarer