Skip to content

vkchang39/bootcamp

Repository files navigation

BOOTCAMP API

Backend API for DevCamper application, which is a bootcamp directory website

Usage

Rename "config/config.env.env" to "config/config.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

Database Seeder

To seed the database with users, bootcamps, courses and reviews with data from the "_data" folder, run

# Destroy all data
node seeder -d

# Import all data
node seeder -i
  • Version: 1.0.0
  • License: MIT
  • Author: Vijay Kumar

API

Indices


Authentication

Routes for using user authentication for register, login, reset password, etc.

1. Forgot Password

Generate forgot password token and send an email.

Endpoint:

Method: GET
Type: RAW
URL: {{URL}}/api/v1/auth/forgotpassword

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "email":"mary@gmail.com"
}

2. Getting User

getting logged in user details

Endpoint:

Method: GET
Type: RAW
URL: {{URL}}/api/v1/auth/me

Headers:

Key Value Description
Content-Type application/json JSON type

3. Login a User

verify login credentials in database.

Endpoint:

Method: POST
Type: RAW
URL: {{URL}}/api/v1/auth/login

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "email":"aman@aman.com",
    "password":"123456"
}

4. Logout a User

clear token cookie and logout a user.

Endpoint:

Method: GET
Type: RAW
URL: {{URL}}/api/v1/auth/logout

5. New Request

Endpoint:

Method: GET
Type:
URL:

6. Register User

Add a user to database with encrypted password.

Endpoint:

Method: POST
Type: RAW
URL: {{URL}}/api/v1/auth/register

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "name":"aman kumar",
    "email":"aman@aman.com",
    "password":"amankumar"
}

7. Reset Password

reset password with token

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/auth/resetpassword/d5b6c512cf0181dfa9e23892e76c2e9e9ed29953fbf6f1e484

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "password":1234566
}

8. Update USER Details

update loggedin user, only name

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/auth/updatedetails

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "name": "aman",
    "email": "aman@aman.com"
}

9. Update USER Password

Update logged in user's password by providing currentPassword.

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/auth/updatepassword

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "currentPassword":"amankumar",
    "newPassword": "123456"

}

Bootcamps

Bootcamps CRUD functionality.

1. Create new Bootcamp

Add new Bootcampt to database. Must be authenticated. Must be Autor or Admin.

Endpoint:

Method: POST
Type: RAW
URL: {{URL}}/api/v1/bootcamps

Headers:

Key Value Description
Content-Type application/json JSON type
Authorization Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYwNDk5YjExYmM3N2RhMmYwY2Y2M2Q0NyIsImlhdCI6MTYxNTUwNTgwMywiZXhwIjoxNjE4MDk3ODAzfQ.r9r7ioIdShFO044TsUyHs5n0g17-wHPNLcpu3RdWD98

Body:

{
    "name": "Test Bootcamp",
		"description": "ModernTech has one goal, and that is to make you a rockstar developer and/or designer with a six figure salary. We teach both development and UI/UX",
		"website": "https://moderntech.com",
		"phone": "(222) 222-2222",
		"email": "enroll@moderntech.com",
		"address": "220 Pawtucket St, Lowell, MA 01854",
		"careers": ["Web Development", "UI/UX", "Mobile Development"],
		"housing": false,
		"jobAssistance": true,
		"jobGuarantee": false,
		"acceptGi": true
}

2. Delete Bootcamp

Delete Bootcamp from database

Endpoint:

Method: DELETE
Type:
URL: {{URL}}/api/v1/bootcamps/604ab5e62625081964fcf298

3. Get all Bootcamps

Feth all Bootcamps from database. Includes pagination, filtering, etc

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/bootcamps

4. Get single Bootcamp

Get single Bootcamp by ID.

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/bootcamps/5ff1a8f8c0586a347892ec9a

5. Update Bootcamp

Update single Bootcamp in database.

Endpoint:

Method: PUT
Type:
URL: {{URL}}/api/v1/bootcamps/1

6. Upload File

Route to upload a file to bootcamp.

Endpoint:

Method: PUT
Type:
URL: {{URL}}/api/v1/bootcamps/5d725a1b7b292f5f8ceff788/photo

Courses

Create, Update, Delete Courses

1. Create a Bootcamp course

create a course for a specific boorcamp.

Endpoint:

Method: POST
Type: RAW
URL: {{URL}}/api/v1/bootcamps/5d713995b721c3bb38c1f5d0/courses

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
		"title": "Full Stack Web Development",
		"description": "In this course you will learn full stack web development, first learning all about the frontend with HTML/CSS/JS/Vue and then the backend with Node.js/Express/MongoDB",
		"weeks": 12,
		"tuition": 10000,
		"minimumSkill": "intermediate",
		"scholarhipsAvailable": true
        }

2. Delete a Course

delete a course from database by id

Endpoint:

Method: DELETE
Type:
URL: {{URL}}/api/v1/courses/5d725a4a7b292f5f8ceff789

3. Get Courses from a Bootcamp

get all courses from a specific bootcamp

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/bootcamps/5d725a1b7b292f5f8ceff788/courses

4. Get a single Course

get a single course by id

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/courses/5d725a4a7b292f5f8ceff789

5. Get all Courses

Get all Courses in database.

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/courses

6. Update a Course

update a course in database with id

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/courses/5d725a4a7b292f5f8ceff789

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "weeks": 10
}

Reviews

Manage course reviews.

1. Add review for bootcamp

Insert review for a specific bootcamp.

Endpoint:

Method: POST
Type: RAW
URL: {{URL}}/api/v1/bootcamps/5d725a1b7b292f5f8ceff788/reviews

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "title":"Nice Bootcamp",
    "text":"Bootcamp is amazing",
    "rating": 9
}

2. Delete a review for bootcamp

logged in user and admin can delete their review.

Endpoint:

Method: DELETE
Type: RAW
URL: {{URL}}/api/v1/reviews/605ca27728e52d46e8b85721

3. Get all reviews.

Get all reviews from database and populate it with bootcamp name and description.

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/reviews

4. Get reviews for bootcamp.

get the reviews for a specific bootcamp.

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/bootcamps/5d725a1b7b292f5f8ceff788/reviews

5. Get single review.

get a single review from dataabase and populate it with bootcamp name and description.

Endpoint:

Method: GET
Type:
URL: {{URL}}/api/v1/reviews/5d7a514b5d2c12c7449be025

6. Update a review for bootcamp

logged in users can update their review for bootcamp.

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/reviews/605ca27728e52d46e8b85721

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "title":"Good Bootcamp",
    "text":"Bootcamp is amazing",
    "rating": 9
}

USERS

CRUD functionality for user, only available to admins.

1. Create User

Create users in database by admin.

Endpoint:

Method: POST
Type: RAW
URL: {{URL}}/api/v1/users

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "name":"aman kumar admin",
    "email":"aman@admin.com",
    "password":"amankumar"
}

2. Delete a User

delete a user from database

Endpoint:

Method: DELETE
Type: RAW
URL: {{URL}}/api/v1/users/5d7a514b5d2c12c7449be045

Headers:

Key Value Description
Content-Type application/json JSON type

3. Getting User

getting all users by admin with advanced results

Endpoint:

Method: GET
Type: RAW
URL: {{URL}}/api/v1/users

Headers:

Key Value Description
Content-Type application/json JSON type

4. Getting single User

getting single user from database by his/her id.

Endpoint:

Method: GET
Type: RAW
URL: {{URL}}/api/v1/users/60574352977b1c22f83b03a3

Headers:

Key Value Description
Content-Type application/json JSON type

5. Update USER Details

update any detail of an user by admin.

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/users/60574352977b1c22f83b03a3

Headers:

Key Value Description
Content-Type application/json JSON type

Body:

{
    "name": "aman",
    "email": "aman@aman.com"
}

Back to top

Made with ♥ by vijayKumar | Generated at: 2021-03-26 00:39:34 by docgen

About

simple bootcamp

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published