update user

This commit is contained in:
Le Viet
2022-03-15 16:53:48 +07:00
parent 870e5b089e
commit 4e8d728142
4 changed files with 386 additions and 242 deletions
+4 -225
View File
@@ -1,227 +1,6 @@
const memberController = require("../controllers").member;
const auth = require("../middleware/auth");
module.exports = app => {
/**
* @swagger
* /v1/user/register:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* username:
* type: string
* description: The user's username.
* example: test@float.sg
* email:
* type: string
* description: The user's email.
* example: test@float.sg
* password:
* type: string
* description: The user's password.
* example: test@float.sg
* firstname:
* type: string
* description: The user's firstname.
* example: Float
* lastname:
* type: string
* description: The user's lastname.
* example: Mobility
* phone:
* type: string
* description: The user's phone.
* example: 123456789
* responses:
* 200:
* description: Created
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: striing
* description: Message
* example: Register successfully
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: striing
* description: Message
* example: Failed
*/
app.post("/api/v1/user/register", memberController.validate('register'), memberController.register);
/**
* @swagger
* /v1/user/login:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* username:
* type: string
* description: The user's username.
* example: test@float.sg
* password:
* type: string
* description: The user's password.
* example: test@float.sg
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* accessToken:
* type: string
* description: Message
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RAZmxvYXQuc2ciLCJpYXQiOjE2NDcwODIxNDIsImV4cCI6MTY0NzA4Mzk0Mn0.fMQYB4ielKPh21QcZFwOJSjlGNCAg8rkvEcKWctxdX8
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong username or password
*/
app.post("/api/v1/user/login", memberController.login);
/**
* @swagger
* /v1/user/forgot-password:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: The user's username.
* example: test@float.sg
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Email has been sent
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong email
*/
app.post("/api/v1/user/forgot-password", memberController.forgotPassword);
/**
* @swagger
* /v1/user/reset-password:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: The user's username.
* example: test@float.sg
* mode:
* type: integer
* description: The reset mode (100: start, 200:confirm, 300:complete)
* example: 100
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* accessToken:
* type: string
* description: Message
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RAZmxvYXQuc2ciLCJpYXQiOjE2NDcwODIxNDIsImV4cCI6MTY0NzA4Mzk0Mn0.fMQYB4ielKPh21QcZFwOJSjlGNCAg8rkvEcKWctxdX8
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong username or password
*/
app.post("/api/v1/user/reset-password", memberController.resetPassword);
/**
* @swagger
* /v1/user/profile:
* get:
* tags:
* - Users
* summary: Retrieve a single JSONPlaceholder user.
* description: Retrieve a single JSONPlaceholder user. Can be used to populate a user profile when prototyping or testing an API.
* security: # <--- ADD THIS
* - bearerAuth: [] # <--- ADD THIS
* responses:
* 200:
* description: A single user.
* content:
* application/json:
* schema:
* type: object
* $ref: '#/components/schemas/Member'
*/
app.get("/api/v1/user/profile", auth, memberController.profile);
const member = require("./member");
const url = '/api/v1/';
module.exports = (app) => {
member(app, url)
};
+323
View File
@@ -0,0 +1,323 @@
const memberController = require("../controllers").member;
const auth = require("../middleware/auth");
module.exports = (app, url) => {
/**
* @swagger
* /v1/user/register:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* username:
* type: string
* description: The user's username.
* example: test@float.sg
* email:
* type: string
* description: The user's email.
* example: test@float.sg
* password:
* type: string
* description: The user's password.
* example: test@float.sg
* firstname:
* type: string
* description: The user's firstname.
* example: Float
* lastname:
* type: string
* description: The user's lastname.
* example: Mobility
* phone:
* type: string
* description: The user's phone.
* example: 123456789
* responses:
* 200:
* description: Created
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: striing
* description: Message
* example: Register successfully
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: striing
* description: Message
* example: Failed
*/
app.post(url + "user/register", memberController.validate('register'), memberController.register);
/**
* @swagger
* /v1/user/login:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* username:
* type: string
* description: The user's username.
* example: test@float.sg
* password:
* type: string
* description: The user's password.
* example: test@float.sg
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* accessToken:
* type: string
* description: Message
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RAZmxvYXQuc2ciLCJpYXQiOjE2NDcwODIxNDIsImV4cCI6MTY0NzA4Mzk0Mn0.fMQYB4ielKPh21QcZFwOJSjlGNCAg8rkvEcKWctxdX8
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong username or password
*/
app.post(url + "user/login", memberController.login);
/**
* @swagger
* /v1/user/forgot-password:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: The user's username.
* example: test@float.sg
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Email has been sent
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong email
*/
app.post(url + "user/forgot-password", memberController.forgotPassword);
/**
* @swagger
* /v1/user/reset-password:
* post:
* tags:
* - Users
* summary: Create a JSONPlaceholder user.
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* email:
* type: string
* description: The user's username.
* example: test@float.sg
* mode:
* type: integer
* description: The reset mode
* example: 100
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* accessToken:
* type: string
* description: Message
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RAZmxvYXQuc2ciLCJpYXQiOjE2NDcwODIxNDIsImV4cCI6MTY0NzA4Mzk0Mn0.fMQYB4ielKPh21QcZFwOJSjlGNCAg8rkvEcKWctxdX8
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong username or password
*/
app.post(url + "user/reset-password", memberController.resetPassword);
/**
* @swagger
* /v1/user/profile:
* get:
* tags:
* - Users
* summary: Retrieve a single JSONPlaceholder user.
* description: Retrieve a single JSONPlaceholder user. Can be used to populate a user profile when prototyping or testing an API.
* security:
* - bearerAuth: []
* responses:
* 200:
* description: A single user.
* content:
* application/json:
* schema:
* type: object
* $ref: '#/components/schemas/Member'
*/
app.get(url + "user/profile", auth, memberController.profile);
/**
* @swagger
* /v1/user/update:
* put:
* tags:
* - Users
* summary: Update User profile
* description: update user's profile
* security:
* - bearerAuth: []
* responses:
* 200:
* description: A single user.
* content:
* application/json:
* schema:
* type: object
* $ref: '#/components/schemas/Member'
*/
app.put(url + "user/update", auth, memberController.updateProfile);
/**
* @swagger
* /v1/user/change-password:
* put:
* tags:
* - Users
* summary: Update User profile
* description: update user's profile
* security:
* - bearerAuth: []
* responses:
* 200:
* description: Login success
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Email has been sent
* 400:
* description: Invalid
* content:
* application/json:
* schema:
* type: object
* properties:
* message:
* type: string
* description: Message
* example: Wrong email
*/
app.put(url + "user/change-password", auth, memberController.changePassword);
/**
* app.post("tracklocation");
* app.post("savecardpayment");
* app.post("getcardpaymentlist");
* app.post("managepaymentlist");
* app.post("verifysession");
* app.post("refreshsession");
* app.post("linkemail");
* app.post("refreshlinkemail");
* app.post("usertransportlist");
* app.post("usertransportprofile");
* app.post("getdashcarddata");
* app.post("loadsavedcards");
* app.post("loadsavedcards");
* app.post("savedashcard");
* app.post("saveuserbudget");
* app.post("resetpass");
* app.post("settingsarray");
* app.post("loadsubsription");
* app.post("subscriptionstatus");
* app.post("getapplist");
* app.post("getslidecarddata");
* app.post("subscribedcarddata");
* app.post("subscribecard");
* app.post("savesurvey");
* app.post("pointsdetail");
* app.post("loadredeemabale");
* app.post("redeempoints");
* app.post("managefeature");
* app.post("carpool");
* app.post("logout");
* app.post("logout");
* app.post("carpoolstatus");
* app.post("getsavedtrips");
* app.post("savedtrip");
* app.post("removesavedtrip");
* app.post("trackcardclick");
* app.post("membersettings");
* app.post("persnoality");
*/
};