Skip to content

Commit

Permalink
ft(comment): Complete endpoint for user to delete comment
Browse files Browse the repository at this point in the history
  • Loading branch information
richienabuk committed Sep 11, 2019
1 parent f1a3eae commit a8644b8
Show file tree
Hide file tree
Showing 21 changed files with 320 additions and 418 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
],
"rules": {
"one-var": 0,
"arrow-parens": 0,
"one-var-declaration-per-line": 0,
"new-cap": 0,
"consistent-return": 0,
"linebreak-style": 0,
"no-param-reassign": 0,
"no-trailing-spaces": 0,
"comma-dangle": 0,
"camelcase": 0,
"no-unused-expressions": 0,
"arrow-parens": 0,
"class-methods-use-this": 0,
"curly": ["error", "multi-line"],
"import/no-unresolved": [2, { "commonjs": true }],
"no-shadow": ["error", { "allow": ["req", "res", "err"] }],
Expand Down
2 changes: 1 addition & 1 deletion .sequelizerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require('path');

module.exports = {
"config": path.resolve('./src/config', 'config.js'),
"models-path": path.resolve('./src/models'),
"models-path": path.resolve('./src/models'),
"seeders-path": path.resolve('./src/database/seeders'),
"migrations-path": path.resolve('./src/database/migrations')
};
264 changes: 13 additions & 251 deletions public/docs/swaggerDoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,145 +472,6 @@
}
}
},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"name": "token",
"in": "header"
}
},
"/api/v1/trips": {
"post": {
"tags": ["Comment"],
"summary": "Allow users to comment on a trip request",
"description": "",
"operationId": "CommentOnTripRequest",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "type",
"in": "body",
"description": "comment details",
"required": true,
"schema": {
"type": "object",
"properties": {
"trip_request_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"message": {
"type": "string",
"example": "Please approve my trip request"
}
}
}
}
],
"produces": ["application/json"],
"responses": {
"201": {
"description": "Comment Created Successfully",
"name": "type",
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"user_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"trip_request_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"message": {
"type": "string",
"example": "Please approve my trip request"
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
}
}
},
"404": {
"description": "trip request details not found"
},
"403": {
"description": "A user is forbidden to comment on a trip request"
}
}
}
},
"api/v1/comment/trips/:commentUuid": {
"put": {
"tags": ["Comment"],
"summary": "Update the comment on a trip request",
"description": "",
"consumes": "application/json",
"operationId": "UpdatePropertyPrice",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "commentUuid",
"in": "path",
"description": "uuid of comment to update",
"required": true,
"type": "string"
}
],
"produces": ["application/json"],
"responses": {
"200": {
"description": "comment that has been updated",
"name": "type",
"in": "body",
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"user_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"trip_request_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"message": {
"type": "string",
"example": "Please approve my trip request"
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
}
}
}
}
}
},
"/api/v1/comment/trips": {
"post": {
"tags": ["Comment"],
Expand Down Expand Up @@ -743,134 +604,35 @@
}
}
},
"/api/v1/comment/trips": {
"post": {
"tags": ["Comment"],
"summary": "Allow users to comment on a trip request",
"description": "",
"operationId": "CommentOnTripRequest",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "type",
"in": "body",
"description": "comment details",
"required": true,
"schema": {
"type": "object",
"properties": {
"trip_request_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"message": {
"type": "string",
"example": "Please approve my trip request"
}
}
}
}
"api/v1/comment/trips/:uuid": {
"delete": {
"tags": [
"Comment"
],
"produces": ["application/json"],
"responses": {
"201": {
"description": "Comment Created Successfully",
"name": "type",
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"user_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"trip_request_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"message": {
"type": "string",
"example": "Please approve my trip request"
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
}
}
},
"404": {
"description": "trip request details not found"
},
"403": {
"description": "A user is forbidden to comment on a trip request"
}
}
}
},
"api/v1/comment/trips/:commentUuid": {
"put": {
"tags": ["Comment"],
"summary": "Update the comment on a trip request",
"description": "",
"summary": "Delete a user's comment",
"description": "Deletes a user's comment",
"consumes": "application/json",
"operationId": "UpdatePropertyPrice",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "commentUuid",
"name": "uuid",
"in": "path",
"description": "uuid of comment to update",
"description": "uuid of comment to delete",
"required": true,
"type": "string"
}
],
"produces": ["application/json"],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "comment that has been updated",
"name": "type",
"in": "body",
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"user_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"trip_request_uuid": {
"type": "string",
"example": "95ccd25d-2524-4b95-a441-8e2643c4c075"
},
"message": {
"type": "string",
"example": "Please approve my trip request"
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
}
}
"description": "Comment deleted successful",
"name": "type"
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/controllers/AdminController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable class-methods-use-this */
import UserRepository from '../repositories/UserRepository';
import { sendSuccessResponse, sendErrorResponse, successResponse } from '../utils/sendResponse';
import { inValidEmail } from '../modules/validator';
Expand Down
10 changes: 3 additions & 7 deletions src/controllers/AuthController.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable camelcase */
import UserRepository from '../repositories/UserRepository';
import { blackListThisToken } from '../utils';
import { createToken, verifyToken } from '../modules/tokenProcessor';
import { sendErrorResponse, successResponse, sendSuccessResponse } from '../utils/sendResponse';
import { inValidEmail, inValidPassword, magicTrimmer } from '../modules/validator';
import sendEmail from '../services/emails';
import { hashPassword, unhashPassword } from '../utils/hashPassword';
import userInfo from '../utils/getUserInfo';

import userInfo from '../utils/createAccessToken';

/**
* @description User controller
Expand Down Expand Up @@ -225,7 +222,7 @@ class AuthController {
}
return sendErrorResponse(res, 400, 'User not found');
} catch (error) {
next(error);
return next(error);
}
}

Expand Down Expand Up @@ -275,10 +272,9 @@ class AuthController {
return sendErrorResponse(res, 409, `User ${email} already exists`);
}
} catch (error) {
next(error);
return next(error);
}
}
}


export default new AuthController();
Loading

0 comments on commit a8644b8

Please sign in to comment.