Skip to content

Back-end API for Feed Me website which helps users to find the nearest restaurants around, Made using NodeJS, Express, MongoDB.

Notifications You must be signed in to change notification settings

SamehEtman/Feed-Me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Back end API for Feed-me website which helps your find the restaurants around you

Usage

Rename "config/dev.env.env" to "config/dev.env" and update the values/settings to your own

Install Dependencies

npm install

Run App

# Run in dev mode
npm run dev
# Run in prod mode
npm start

Documentaion

  • The app is launched to heroku : feed-me

Indices


Admin

Admin CRUD operations

1. Create user

Create a new user

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/admin

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "hello",
    "email" : "[email protected]",
    "password" : "123456"
}

2. Delete user

Delete a user by id

Endpoint:

Method: DELETE
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/admin/611ab2e3d18a4c075b72bafa

3. Get a single user

Fetch a user by id

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/admin/611ab2d9d18a4c075b72baf8

4. Get all users

Fetch all users in the database

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/admin

Query params:

Key Value Description
sort -createdAt
skip 1
limit 1

5. Update user

Update a user by id

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/admin/611ab2d9d18a4c075b72baf8

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "edited"
}

Restaurants

Restaurants CRUD operations

1. Create restaurant

Create a new restaurant

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "Adam Cafe2",
    "email" : "[email protected]",
    "address" : "shobra millis zefta",
    "averageRating" : 8
}

2. Delete restaurant

Delete a restaurant by id, Requires an authenticated user.

Endpoint:

Method: DELETE
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/6118604f91f10dbc32670992

3. Get all restaurants

Fetch all restaurants in the database

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants

4. Get restaurant within radius

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/radius

Query params:

Key Value Description
lat 30.852144
lon 31
radius 50

5. Update restaurant

Update a restaurant by id, Requires an authenticated user.

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611ab3cbd18a4c075b72bb23

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "edited"
}

6. Update restaurant picture

Update restaurant picture

Endpoint:

Method: PUT
Type: FORMDATA
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611ab3cbd18a4c075b72bb23/photo

Body:

Key Value Description
file

7. get single restaurant

Fetch a single restaurant by id

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611ab3cbd18a4c075b72bb23

Reviews

CRUD operations for reviews , Publishers aren't allowed to post reviews, only users can do that.

1. Create a review

Create a review for a restaurant , requires user role and authentication.

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611ab3cbd18a4c075b72bb23/reviews

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "title" : "bad restaur",
    "text": "hate every thing",
    "rating" : 7
}

2. Delete review

Delete a review , requires authentication

Endpoint:

Method: DELETE
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/reviews/611ac868ea5b915230f0d1fa

3. Get a single reveiw

Fetch a single review by id

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/reviews/611ac0a36029ca31bea1336a

4. Get all reviews

Fetch all the reviews in the database

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/reviews

5. Get reviews for a specific restaurant

Fetch all reviews for a specific restaurant

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611ab3cbd18a4c075b72bb23/reviews

6. Update review

Update a review , requires authentication.

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/reviews/611ac866ea5b915230f0d1f4

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "rating":10
}

Servings

Servings CRUD operations

1. Create Serving

Create a serving for a specific restaurant , requires publisher role and authenticated user .

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611ab3cbd18a4c075b72bb23/servings

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "crep4",
    "price" : 50,
    "components" : ["katchap" , "bread" , "chicken"],
    "description" : "syrian good crep"
}

2. Delete serving

Delete a serving , requires publisher role and authenticated user .

Endpoint:

Method: DELETE
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/servings/611ab3ddd18a4c075b72bb2b

3. Get all servings

Fetch all servings

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/servings

4. Get servings for specific restaurant

Fetch all servings of a specific restaurant

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/restaurants/611861b55ee30ec300cd5e5d/servings

5. Get single serving

Fetch serving by id

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/servings/611ab3d9d18a4c075b72bb27

6. Update a serving

update a serving , requires publisher role and authenticated user .

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/servings/611ab3ddd18a4c075b72bb2b

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "edited"
}

Users

Users CRUD operations

1. Create user

Create a new user

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/signup

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name":"user",
    "email" :"[email protected]",
    "password" : "123456"
}

2. Delete user

Delete authenticated user's account

Endpoint:

Method: DELETE
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/deleteuser

3. Forgot password

This route is for resetting your forgotten password, It sends an email to your email address which contains a link to your reset password page

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/forgotpassword

Body:

{
    "email" : "[email protected]"
}

4. Get user Profile

Fetch the authenticated user's details

Endpoint:

Method: GET
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/me

5. Login user

Endpoint:

Method: POST
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/login

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "email" :"[email protected]",
    "password" : "123456"
}

6. Logout user

Logout user , Clear cookies

Endpoint:

Method: POST
Type: 
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/logout

7. Reset password

Reset password route

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/resetpassword/2764ebbbfa2d41e72fe8de3b239b7f24e1165ea2

Body:

{
    "password" : "1235456"
}

8. Update password

Update authenticated users's password, current password and new password are needed

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/updatepassword

Body:

{
    "currentPassword": "1234A56",
    "newPassword" : "123456"
}

9. Update user details

Update authenticated user's details

Endpoint:

Method: PUT
Type: RAW
URL: https://sameh-feed-me.herokuapp.com/api/v1/users/updatedetails

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "name" : "edited",
    "email":"[email protected]"
}

Available Variables:

Key Value Type
url https://sameh-feed-me.herokuapp.com

Back to top

Made with ♥ by thedevsaddam | Generated at: 2021-08-17 00:58:56 by docgen

About

Back-end API for Feed Me website which helps users to find the nearest restaurants around, Made using NodeJS, Express, MongoDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published