Backend RESTful API built with NodeJS, ExpressJS, MongoDB and Mongoose. Besides CRUD functionalities, this API covers authentication, authorization, image uploads and security preventions.
Rename "config/renamethis.env" to "config/config.env" and update your credentials in there.
npm install
# Run in dev mode
npm run dev
# Run in prod mode
npm start
Routes for authentication including register, login, reset password etc
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]"
}
Get current user via token
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/auth/me
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"
}
Clear token cookies
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/auth/logout
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"
}
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"
}
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"
}
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 CRUD functionality
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
}
Delete bootcamp from database
Endpoint:
Method: DELETE
Type:
URL: {{URL}}/api/v1/bootcamps/60c5d59baaf0d053967af896
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 |
Get single bootcamp by id
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/bootcamps/60be3c40d1dd1ff2d26b71cd
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
}
Route to upload a bootcamp photo
Endpoint:
Method: PUT
Type: FORMDATA
URL: {{URL}}/api/v1/bootcamps/5d725a1b7b292f5f8ceff788/photo
Body:
Key | Value | Description |
---|---|---|
file |
Create, read, update and delete courses
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
}
Delete course with id
Endpoint:
Method: DELETE
Type:
URL: {{URL}}/api/v1/courses/60c20b506cf961abf5f50e59
Get the specific course for a bootcamp
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/bootcamps/5d713995b721c3bb38c1f5d0/courses
Get all courses in the database
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/courses
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/courses/5d725cb9c4ded7bcb480eaa1
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"
}
Get all users with Admin acess
Endpoint:
Method: GET
Type:
URL: {{URL}}/api/v1/users
Made with โฅ by thedevsaddam | Generated at: 2021-06-15 16:05:38 by docgen