Merge branch 'main' into yashrajverma
This commit is contained in:
commit
b31361fb4e
|
@ -9,8 +9,8 @@ const { getAllCoupons } = require('./coupon');
|
||||||
|
|
||||||
//test credentials of razorpay
|
//test credentials of razorpay
|
||||||
const instance = new razorpay({
|
const instance = new razorpay({
|
||||||
key_id : 'rzp_test_tLx9c6GiWjKcsl' ,
|
key_id : process.env.KEY_ID ,
|
||||||
key_secret : '4Cf52d6C3amkptdRLCTdC2sT'
|
key_secret : process.env.KEY_SECRET
|
||||||
}) ;
|
}) ;
|
||||||
|
|
||||||
module.exports.postVerify =async (req , res , next) => {
|
module.exports.postVerify =async (req , res , next) => {
|
||||||
|
@ -108,6 +108,9 @@ module.exports.postRazorpay = async (req , res , next) => {
|
||||||
const courseId = req.body.courseId ;
|
const courseId = req.body.courseId ;
|
||||||
const couponCode = req.body.couponCode ;
|
const couponCode = req.body.couponCode ;
|
||||||
const userId = req.user._id ;
|
const userId = req.user._id ;
|
||||||
|
|
||||||
|
console.log("Course ID =" ,courseId ," Coupon code =" , couponCode ," user ID =" , userId) ;
|
||||||
|
|
||||||
let user = await User.findById(userId) ;
|
let user = await User.findById(userId) ;
|
||||||
let student =await Student.findById(user.student) ;
|
let student =await Student.findById(user.student) ;
|
||||||
let course =await CourseType.findById(courseId) ;
|
let course =await CourseType.findById(courseId) ;
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
"env" : {
|
"env" : {
|
||||||
"MONGO_USER":"Cantilever",
|
"MONGO_USER":"Cantilever",
|
||||||
"MONGO_PASSWORD" :"Cantilever" ,
|
"MONGO_PASSWORD" :"Cantilever" ,
|
||||||
"MONGO_DEFAULT_DATABASE" :"myFirstDatabase"
|
"MONGO_DEFAULT_DATABASE" :"myFirstDatabase" ,
|
||||||
|
"KEY_ID" : "rzp_live_aD9j5WLBGtdQxt" ,
|
||||||
|
"KEY_SECRET" : "o9BDCwYcpNcHyFL5yjiY7OWG" ,
|
||||||
|
"EMAIL" : "AKIA2G7743RRTZMVXE3X" ,
|
||||||
|
"HOST" : "email-smtp.us-east-1.amazonaws.com" ,
|
||||||
|
"PASS" : "BJSjV3jArJfsnk1LhFc/hUmisEyEtbLNGgrRbv0noh8c"
|
||||||
}
|
}
|
||||||
}
|
}
|
400
readme.md
400
readme.md
|
@ -1,197 +1,193 @@
|
||||||
# Cantileverlabs Nodejs Backend API Documentation.
|
# Cantileverlabs Nodejs Backend API Documentation.
|
||||||
|
## 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`
|
||||||
|
|
||||||
## Project Structure :
|
# Routes Functions and Body Parameters.
|
||||||
|
|
||||||
```
|
## File :- Admin.js
|
||||||
/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`
|
```
|
||||||
|
Route : /addSchedule
|
||||||
|
Method: POST
|
||||||
|
Requirements : |-- isAuth
|
||||||
|
|-- isAdmin
|
||||||
|
|
||||||
# Routes Functions and Body Parameters.
|
Route : /editSchedule
|
||||||
|
Method: POST
|
||||||
|
Requirements : |-- isAuth
|
||||||
|
|-- isAdmin
|
||||||
|
|
||||||
## File :- Admin.js
|
Route : /deleteSchedule
|
||||||
|
Method: POST
|
||||||
```
|
Requirements : |-- isAuth
|
||||||
Route : /addSchedule
|
|-- isAdmin
|
||||||
Method: POST
|
|
||||||
Requirements : |-- isAuth
|
|
||||||
|-- isAdmin
|
|
||||||
|
|
||||||
Route : /editSchedule
|
|
||||||
Method: POST
|
|
||||||
Requirements : |-- isAuth
|
|
||||||
|-- isAdmin
|
|
||||||
|
|
||||||
Route : /deleteSchedule
|
|
||||||
Method: POST
|
|
||||||
Requirements : |-- isAuth
|
|
||||||
|-- isAdmin
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## File :- Auth.js
|
## File :- Auth.js
|
||||||
|
### Note: `All the Body Params are as it is`
|
||||||
|
|
||||||
### Note: `All the Body Params are as it is`
|
```
|
||||||
|
Route : /protected
|
||||||
```
|
Method: GET
|
||||||
Route : /protected
|
Requirements : |-- isAuth
|
||||||
Method: GET
|
|
||||||
Requirements : |-- isAuth
|
|
||||||
|
|
||||||
|
|
||||||
Route : /signup
|
Route : /signup
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params :- firstName
|
Body Params :- firstName
|
||||||
- lastName
|
- lastName
|
||||||
- email *must*
|
- email *must*
|
||||||
- password *must*
|
- password *must*
|
||||||
---------- for sending the Verification Emial to user.
|
---------- for sending the Verification Emial to user.
|
||||||
- sending_company_email
|
- sending_company_email
|
||||||
- subject
|
- subject
|
||||||
Response : {
|
Response : {
|
||||||
message:"You are Registered, Please Login"
|
message:"You are Registered, Please Login"
|
||||||
}
|
}
|
||||||
Response if email verification: {
|
Response if email verification: {
|
||||||
message:"Email sent with 6 Digit OTP , Check your Email"
|
message:"Email sent with 6 Digit OTP , Check your Email"
|
||||||
}
|
}
|
||||||
|
|
||||||
Route : /verifyemail
|
Route : /verifyemail
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params: - otp
|
Body Params: - otp
|
||||||
|
|
||||||
Route : /signin
|
Route : /signin
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : - email
|
Body Params : - email
|
||||||
- password
|
- password
|
||||||
|
|
||||||
Route : /sendotp
|
Route : /sendotp
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : phoneNumber
|
Body Params : phoneNumber
|
||||||
Respone : {id:id} id of the transaction.
|
Respone : {id:id} id of the transaction.
|
||||||
|
|
||||||
Route : /getotp
|
Route : /getotp
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : id , otp
|
Body Params : id , otp
|
||||||
Response : {message:"Code Verified"}
|
Response : {message:"Code Verified"}
|
||||||
|
|
||||||
Route : /forgotpassword
|
Route : /forgotpassword
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : email,link,sending_company_email,subject.
|
Body Params : email,link,sending_company_email,subject.
|
||||||
|
|
||||||
{ - email of the user. }
|
{ - email of the user. }
|
||||||
{ - link is where to send the user for resetting a password. }
|
{ - 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. }
|
{ - sending_company_email is email address of the comapny to send the email to the user. }
|
||||||
{ - subject is email subject }
|
{ - subject is email subject }
|
||||||
|
|
||||||
Route : /resetpassword/:_id/:token
|
Route : /resetpassword/:_id/:token
|
||||||
Method: POST
|
Method: POST
|
||||||
Headers Params : _id, token
|
Headers Params : _id, token
|
||||||
Body Params : password
|
Body Params : password
|
||||||
Response : {message:"Password Updated!"}
|
Response : {message:"Password Updated!"}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## File :- BLog.js
|
## File :- BLog.js
|
||||||
|
|
||||||
```
|
```
|
||||||
Route : /addBlog
|
Route : /addBlog
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : _id , title , body , author , image
|
Body Params : _id , title , body , author , image
|
||||||
|
|
||||||
String : { _id : Database _id of a person who is adding up a blog}
|
String : { _id : Database _id of a person who is adding up a blog}
|
||||||
String : { title : title of the blog}
|
String : { title : title of the blog}
|
||||||
String: { body : body of the blog}
|
String: { body : body of the blog}
|
||||||
String: image of the blog to be added}
|
String: image of the blog to be added}
|
||||||
String : Author of the blog}
|
String : Author of the blog}
|
||||||
|
|
||||||
|
|
||||||
Route : /getAllBlogs
|
Route : /getAllBlogs
|
||||||
Method: GET
|
Method: GET
|
||||||
Body Params : none
|
Body Params : none
|
||||||
|
|
||||||
Route : /deleteBlog
|
Route : /deleteBlog
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : _id * must *
|
Body Params : _id * must *
|
||||||
|
|
||||||
{ _id : _id is a id of the blog to delete.}
|
{ _id : _id is a id of the blog to delete.}
|
||||||
|
|
||||||
Route : /editBlog
|
Route : /editBlog
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : _id * must * , body , title , image.
|
Body Params : _id * must * , body , title , image.
|
||||||
|
|
||||||
String : { _id : Database _id of a person who is adding up a blog}
|
String : { _id : Database _id of a person who is adding up a blog}
|
||||||
String : { title : title of the blog}
|
String : { title : title of the blog}
|
||||||
String: { body : body of the blog}
|
String: { body : body of the blog}
|
||||||
String: image of the blog to be added}
|
String: image of the blog to be added}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## File :- Coupon.js
|
## File :- Coupon.js
|
||||||
|
|
||||||
```
|
```
|
||||||
Route : /set-coupon
|
Route : /set-coupon
|
||||||
Method: POST
|
Method: POST
|
||||||
Body Params : percentage , coupon_code , remainingTimes
|
Body Params : percentage , coupon_code , remainingTimes
|
||||||
|
|
||||||
String : { couponCode : Coupon code of the coupon}
|
String : { couponCode : Coupon code of the coupon}
|
||||||
String: { percentage: Discount percentage of the coupon}
|
String: { percentage: Discount percentage of the coupon}
|
||||||
String: { numAllowed : No of times the coupon is allwoed}
|
String: { numAllowed : No of times the coupon is allwoed}
|
||||||
|
|
||||||
Route : /getAllCoupons
|
Route : /getAllCoupons
|
||||||
Method: GET
|
Method: GET
|
||||||
Body Params : none
|
Body Params : none
|
||||||
|
|
||||||
Route : /deleteCoupon
|
Route : /deleteCoupon
|
||||||
Method: POST
|
Method: POST
|
||||||
Requirements : isAdmin, isAuth
|
Requirements : isAdmin, isAuth
|
||||||
Body Params : couponCode * must *
|
Body Params : couponCode * must *
|
||||||
|
|
||||||
{ couponCode : coupon code of the coupon }
|
{ couponCode : coupon code of the coupon }
|
||||||
|
|
||||||
Route : /addCoupon
|
Route : /addCoupon
|
||||||
Method: POST
|
Method: POST
|
||||||
Requirements : isAdmin, isAuth
|
Requirements : isAdmin, isAuth
|
||||||
Body Params : couponCode * must * , percentage , numAllowed
|
Body Params : couponCode * must * , percentage , numAllowed
|
||||||
|
|
||||||
String : { couponCode : Coupon code of the coupon}
|
String : { couponCode : Coupon code of the coupon}
|
||||||
String: { percentage: Discount percentage of the coupon}
|
String: { percentage: Discount percentage of the coupon}
|
||||||
String: { numAllowed : No of times the coupon is allwoed}
|
String: { numAllowed : No of times the coupon is allwoed}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -231,58 +227,61 @@
|
||||||
Requiremnts : isAuth
|
Requiremnts : isAuth
|
||||||
Body Params : route , userId
|
Body Params : route , userId
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## File Payments.js
|
## 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}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## File Query.js
|
## File Query.js
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -308,4 +307,3 @@
|
||||||
Method : POST
|
Method : POST
|
||||||
Requirements : None
|
Requirements : None
|
||||||
Body Params : type
|
Body Params : type
|
||||||
```
|
|
||||||
|
|
Loading…
Reference in New Issue