2021-05-26 03:05:16 -07:00
|
|
|
# Cantileverlabs Nodejs Backend API Documentation.
|
2021-05-22 09:19:46 -07:00
|
|
|
## Project Structure :
|
|
|
|
```
|
|
|
|
/root
|
|
|
|
|- controllers
|
|
|
|
| |-- admin.js
|
|
|
|
| |-- auth.js
|
|
|
|
| |-- blog.js
|
|
|
|
| |-- coupon.js
|
|
|
|
| |-- course.js
|
|
|
|
| |-- payment.js
|
|
|
|
| |-- profile.js
|
|
|
|
| |-- query.js
|
|
|
|
|
|
|
|
|
|- middlewares
|
|
|
|
| |-- isAdmin.js
|
|
|
|
| |-- requireLogin.js
|
|
|
|
|
|
|
|
|
|- models
|
|
|
|
| |-- Blog.js
|
|
|
|
| |-- Coupon.js
|
|
|
|
| |-- Course.js
|
|
|
|
| |-- CourseType.js
|
|
|
|
| |-- Order.js
|
|
|
|
| |-- query.js
|
|
|
|
| |-- Student.js
|
|
|
|
| |-- User.js
|
|
|
|
|
|
|
|
|
|- routes
|
|
|
|
| |-- admin.js
|
|
|
|
| |-- auth.js
|
|
|
|
| |-- blog.js
|
|
|
|
| |-- Coupon.js
|
|
|
|
| |-- course.js
|
|
|
|
| |-- payment.js
|
|
|
|
| |-- profile.js
|
|
|
|
| |-- query.js
|
|
|
|
|
|
|
|
|
|- app.js
|
|
|
|
```
|
|
|
|
### App will listen on the port `http://localhost:5000`
|
|
|
|
|
|
|
|
# Routes Functions and Body Parameters.
|
|
|
|
|
|
|
|
## File :- Admin.js
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : /addSchedule
|
|
|
|
Method: POST
|
|
|
|
Requirements : |-- isAuth
|
|
|
|
|-- isAdmin
|
|
|
|
|
|
|
|
Route : /editSchedule
|
|
|
|
Method: POST
|
|
|
|
Requirements : |-- isAuth
|
|
|
|
|-- isAdmin
|
|
|
|
|
|
|
|
Route : /deleteSchedule
|
|
|
|
Method: POST
|
|
|
|
Requirements : |-- isAuth
|
|
|
|
|-- isAdmin
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## File :- Auth.js
|
|
|
|
### Note: `All the Body Params are as it is`
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : /protected
|
|
|
|
Method: GET
|
|
|
|
Requirements : |-- isAuth
|
|
|
|
|
|
|
|
|
|
|
|
Route : /signup
|
|
|
|
Method: POST
|
|
|
|
Body Params :- firstName
|
|
|
|
- lastName
|
|
|
|
- email *must*
|
|
|
|
- password *must*
|
|
|
|
---------- for sending the Verification Emial to user.
|
|
|
|
- sending_company_email
|
|
|
|
- subject
|
|
|
|
Response : {
|
|
|
|
message:"You are Registered, Please Login"
|
|
|
|
}
|
|
|
|
Response if email verification: {
|
|
|
|
message:"Email sent with 6 Digit OTP , Check your Email"
|
|
|
|
}
|
|
|
|
|
|
|
|
Route : /verifyemail
|
|
|
|
Method: POST
|
|
|
|
Body Params: - otp
|
|
|
|
|
|
|
|
Route : /signin
|
|
|
|
Method: POST
|
|
|
|
Body Params : - email
|
|
|
|
- password
|
|
|
|
|
|
|
|
Route : /sendotp
|
|
|
|
Method: POST
|
|
|
|
Body Params : phoneNumber
|
|
|
|
Respone : {id:id} id of the transaction.
|
|
|
|
|
|
|
|
Route : /getotp
|
|
|
|
Method: POST
|
|
|
|
Body Params : id , otp
|
|
|
|
Response : {message:"Code Verified"}
|
|
|
|
|
|
|
|
Route : /forgotpassword
|
|
|
|
Method: POST
|
|
|
|
Body Params : email,link,sending_company_email,subject.
|
|
|
|
|
|
|
|
{ - email of the user. }
|
|
|
|
{ - link is where to send the user for resetting a password. }
|
|
|
|
{ - sending_company_email is email address of the comapny to send the email to the user. }
|
|
|
|
{ - subject is email subject }
|
|
|
|
|
|
|
|
Route : /resetpassword/:_id/:token
|
|
|
|
Method: POST
|
|
|
|
Headers Params : _id, token
|
|
|
|
Body Params : password
|
|
|
|
Response : {message:"Password Updated!"}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## File :- BLog.js
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : /addBlog
|
|
|
|
Method: POST
|
|
|
|
Body Params : _id , title , body , author , image
|
|
|
|
|
|
|
|
String : { _id : Database _id of a person who is adding up a blog}
|
|
|
|
String : { title : title of the blog}
|
|
|
|
String: { body : body of the blog}
|
|
|
|
String: image of the blog to be added}
|
|
|
|
String : Author of the blog}
|
|
|
|
|
|
|
|
|
|
|
|
Route : /getAllBlogs
|
|
|
|
Method: GET
|
|
|
|
Body Params : none
|
|
|
|
|
|
|
|
Route : /deleteBlog
|
|
|
|
Method: POST
|
|
|
|
Body Params : _id * must *
|
|
|
|
|
|
|
|
{ _id : _id is a id of the blog to delete.}
|
|
|
|
|
|
|
|
Route : /editBlog
|
|
|
|
Method: POST
|
|
|
|
Body Params : _id * must * , body , title , image.
|
|
|
|
|
|
|
|
String : { _id : Database _id of a person who is adding up a blog}
|
|
|
|
String : { title : title of the blog}
|
|
|
|
String: { body : body of the blog}
|
|
|
|
String: image of the blog to be added}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## File :- Coupon.js
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : /set-coupon
|
|
|
|
Method: POST
|
|
|
|
Body Params : percentage , coupon_code , remainingTimes
|
|
|
|
|
|
|
|
String : { couponCode : Coupon code of the coupon}
|
|
|
|
String: { percentage: Discount percentage of the coupon}
|
|
|
|
String: { numAllowed : No of times the coupon is allwoed}
|
|
|
|
|
|
|
|
Route : /getAllCoupons
|
|
|
|
Method: GET
|
|
|
|
Body Params : none
|
|
|
|
|
|
|
|
Route : /deleteCoupon
|
|
|
|
Method: POST
|
|
|
|
Requirements : isAdmin, isAuth
|
|
|
|
Body Params : couponCode * must *
|
|
|
|
|
|
|
|
{ couponCode : coupon code of the coupon }
|
|
|
|
|
|
|
|
Route : /addCoupon
|
|
|
|
Method: POST
|
|
|
|
Requirements : isAdmin, isAuth
|
|
|
|
Body Params : couponCode * must * , percentage , numAllowed
|
|
|
|
|
|
|
|
String : { couponCode : Coupon code of the coupon}
|
|
|
|
String: { percentage: Discount percentage of the coupon}
|
|
|
|
String: { numAllowed : No of times the coupon is allwoed}
|
|
|
|
|
|
|
|
```
|
2021-05-26 03:05:16 -07:00
|
|
|
|
|
|
|
## File Course.js
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : /addCourse
|
|
|
|
Method : POST
|
|
|
|
Requirements : isAdmin , isAuth
|
2021-05-22 09:19:46 -07:00
|
|
|
Body Params : name , mentor , totalLectures , route
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
Route : /getAllCourse
|
|
|
|
Method : GET
|
|
|
|
Requirements : None
|
|
|
|
Body Params : None
|
|
|
|
|
|
|
|
|
|
|
|
Route : /getSingleParCourse
|
|
|
|
Method : POST
|
2021-05-22 09:19:46 -07:00
|
|
|
Body Params : parCourseId
|
|
|
|
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
Route : /getMeetSchedule
|
|
|
|
Method : POST
|
|
|
|
Requiremnents : isAuth
|
2021-05-22 09:19:46 -07:00
|
|
|
Body Params : courseId
|
|
|
|
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
Route : /getFromRoute
|
|
|
|
Method : GET
|
|
|
|
Requirements : None
|
|
|
|
Query Params : route
|
2021-05-22 09:19:46 -07:00
|
|
|
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
Route : /addClick
|
|
|
|
Method : POST
|
|
|
|
Requiremnts : isAuth
|
2021-05-22 09:19:46 -07:00
|
|
|
Body Params : route , userId
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## File Payments.js
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Route : /verification
|
|
|
|
Method : POST
|
|
|
|
Requirements : None
|
|
|
|
Body Params :
|
|
|
|
|
|
|
|
|
|
|
|
Route : /razorpay
|
|
|
|
Method : POST
|
|
|
|
Requirements : requireLogin
|
|
|
|
Body Params : courseId , couponCode
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## File Profle.js
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : getProfile
|
|
|
|
Method : GET
|
|
|
|
Requirements : requireLogin
|
|
|
|
Body Params : _id of the User.
|
|
|
|
|
|
|
|
|
|
|
|
Route : postProfile
|
|
|
|
Method : POST
|
|
|
|
Requirements : requireLogin
|
|
|
|
Body Params : _id , interests , projects , yearofgrad , phoneNumber , institute , skills
|
|
|
|
|
|
|
|
Route : deleteUser
|
|
|
|
Method : POST
|
|
|
|
Requirements : requireLogin
|
|
|
|
Body Params : _id
|
|
|
|
{_id : _id of the User to delete the Profile}
|
|
|
|
|
|
|
|
|
|
|
|
Route : editUser
|
|
|
|
Method : POST
|
|
|
|
Requirements : requireLogin
|
|
|
|
Body Params : _id , newFirstName , newLastName ,email
|
|
|
|
|
|
|
|
{_id : _id of the user to edit the profile}
|
|
|
|
{newFirstName : New Name }
|
|
|
|
{newLastName : New last name}
|
|
|
|
{email : if email has to be changed}
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
```
|
2021-05-22 09:19:46 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
## File Query.js
|
|
|
|
|
|
|
|
```
|
|
|
|
Route : addQuery
|
|
|
|
Method : POST
|
|
|
|
Requirements : None
|
2021-05-22 09:19:46 -07:00
|
|
|
Body Params : fullName , phoneNumber , email , query , other , graduationYear
|
|
|
|
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
Route : getAllQueries
|
|
|
|
Method : GET
|
|
|
|
Requirements : None
|
|
|
|
Body Params : None
|
2021-05-22 09:19:46 -07:00
|
|
|
|
|
|
|
|
|
|
|
Route : getOtherQueries
|
2021-05-26 03:05:16 -07:00
|
|
|
Method : GET
|
|
|
|
Requirements : None
|
|
|
|
Body Params : None
|
2021-05-22 09:19:46 -07:00
|
|
|
|
|
|
|
|
2021-05-26 03:05:16 -07:00
|
|
|
Route : getTypeQueries
|
|
|
|
Method : POST
|
|
|
|
Requirements : None
|
2021-05-27 08:03:54 -07:00
|
|
|
Body Params : type
|