Coder Social home page Coder Social logo

satnaing / devcamper-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 4.0 0.0 576 KB

DevCamper API built with NodeJS, ExpressJS, MongoDB and Mongoose.

Home Page: https://satnaing.github.io/devcamper-api/

JavaScript 99.35% Shell 0.65%
expressjs mongodb mongoose express rest-api

devcamper-api's Introduction

DevCampers API

Backend RESTful API built with NodeJS, ExpressJS, MongoDB and Mongoose. Besides CRUD functionalities, this API covers authentication, authorization, image uploads and security preventions.

Usages

Rename "config/renamethis.env" to "config/config.env" and update your credentials in there.

Install Dependencies

npm install

Run the App

# Run in dev mode
npm run dev

# Run in prod mode
npm start

Indices


Authentication

Routes for authentication including register, login, reset password etc

1. Forgot Password

Generate password token and send email

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

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

2. Get Logged in User

Get current user via token

Endpoint:

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

3. Login User

Login user using email and password

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

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

4. Logout User

Clear token cookies

Endpoint:

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

5. Register User

Add user to db 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": "Publisher Account",
	"email": "[email protected]",
	"password": "123456",
    "role": "publisher"
}

6. Reset Password

Reset Password via generated token

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "password": "1234567890"
}

7. Update Password

Update logged in user password, send in the body currentpassword and password

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "currentpassword": "1234567890",
    "password": "123456"
}

8. Update User Details

Update user name and email

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "name": "John Doe",
    "email": "[email protected]"
}

Bootcamps

Bootcamps CRUD functionality

1. Create New Bootcamp

Add new bootcamp to database. Must be authenticated and must be publisher or admin

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "name": "Devcentral Bootcamp NEW",
		"description": "Is coding your passion? Codemasters will give you the skills and the tools to become the best developer possible. We specialize in front end and full stack web development",
		"website": "https://devcentral.com",
		"phone": "(444) 444-4444",
		"email": "[email protected]",
		"address": "45 Upper College Rd Kingston RI 02881",
		"careers": [
			"Mobile Development",
			"Web Development",
			"Data Science",
			"Business"
		],
		"housing": false,
		"jobAssistance": true,
		"jobGuarantee": true,
		"acceptGi": true
}

2. Delete Bootcamp

Delete bootcamp from database

Endpoint:

Method: DELETE
Type:
URL: {{URL}}/api/v1/bootcamps/60c5d59baaf0d053967af896

3. Get All Bootcamps

Fetch all bootcamps from database. Includes pagination, filtering etc

Endpoint:

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

Query params:

Key Value Description
limit 2
page 2

4. Get Single Bootcamp

Get single bootcamp by id

Endpoint:

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

5. Update Bootcamp

Update single bootcamp and database

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/bootcamps/5d713a66ec8f2b88b8f830b8

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "housing": false
}

6. Upload Photo

Route to upload a bootcamp photo

Endpoint:

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

Body:

Key Value Description
file

Courses

Create, read, update and delete courses

1. Create Course

Create course with bootcampId

Endpoint:

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

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "title": "Kevin Course",
		"description": "This course will provide you with all of the essentials to become a successful frontend web developer. You will learn to master HTML, CSS and front end JavaScript, along with tools like Git, VSCode and front end frameworks like Vue",
		"weeks": 8,
		"tuition": 8000,
		"minimumSkill": "beginner",
		"scholarhipsAvailable": true
}

2. Delete Course

Delete course with id

Endpoint:

Method: DELETE
Type:
URL: {{URL}}/api/v1/courses/60c20b506cf961abf5f50e59

3. Get Courses for Bootcamp

Get the specific course for a bootcamp

Endpoint:

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

4. Get all courses

Get all courses in the database

Endpoint:

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

5. Get single course

Endpoint:

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

6. Update Course

Update course with course id

Endpoint:

Method: PUT
Type: RAW
URL: {{URL}}/api/v1/courses/60c20b506cf961abf5f50e59

Headers:

Key Value Description
Content-Type application/json JSON Type

Body:

{
    "title": "HAHA Update Development"
}

Users

1. Get all Users

Get all users with Admin acess

Endpoint:

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

Back to top

Made with โ™ฅ by thedevsaddam | Generated at: 2021-06-15 16:05:38 by docgen

devcamper-api's People

Contributors

dependabot[bot] avatar satnaing avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.