Code Monkey home page Code Monkey logo

comment-microapi's Introduction

Comments Microservice

Build Status Coverage Status Issues Forks MIT License

This is a microservice that allows user to create comments, edit comments and also flags comment. Users can also reply comments, flag reply and also upvote and downvote comments and replies. Also, origin of these comments are tracked.

For quick navigation:

How it works

Getting Started

Ensure that your local machine has all the required software, listed below, before setting up your local environment.

Requirements

Setup Local Environment

You will first need to setup your local environment and ensure that all configuration files are correctly configured.

  1. Fork the repo.
  2. Clone your forked repo to you local environment.
  3. In your terminal, run npm install.
  4. In your terminal, run cp .env.example .env.
  5. In your terminal, run npm run startDev.

Linting Your Code

  1. Run npm run lint:fix to fix all fixable errors in source code and format with prettier
  2. Run npm run lint to find errors that still remain in your code syntax/format
  3. Ensure you fix any remaining linting errors displayed. Run npm run test:ci to ensure your code matches the test

Testing Your Code

  1. Run npm run test to ensure your code passes all tests

Contributing Your Code

Are you willing to contribute to this project? You can contribute in many areas but primarily in the following areas

  1. Implementing endpoints and controllers
  2. Writing unit tests for endpoints and controllers.
  3. Documentation
  4. Creating middleware and their consumables
  5. Fixing/pointing out bugs
  6. We could use a boost in our code coverage, so any tests to cover untested fucntions is highly welcome

Endpoint Documentation

All responses must follow the format specified in the online swagger documentation. This should be your first go to as this will be the live server with the most trustworthy documentation.

Utility Functions

To facilitate consistent code, a few Utility Functions have been provided and you should use them to send your responses to maintain consistent implementation.

Before Submitting Pull Request

  • Always lint and test your code as stated above

  • Make use of the PR template and edit the placeholders with relevant information. PR descriptions must reference the issue number being fixed, e.g fix #12 or resolve #25.

  • Before pushing your commits, ensure your local/forked repo is synced with the latest updates from the original repo to avoid merge conflicts. You can safely do this with a fast-forwards merge.

git remote add upstream https://github.com/microapidev/comment-microapi.git
git fetch upstream
git merge upstream/develop
git commit
git push origin <branch-name>

For more information on the contributing guidelines and implementation details, please see the contributing documentation.

Schema Design

  • Organization Model
  • Admin Model
  • Application Model
  • Comments Model
  • Replies Model
  • Users Model

Please see the complete Schema Design Document.

License

MIT License

Copyright (c) 2020, Team Justice League. All rights reserved.

comment-microapi's People

Contributors

adebayoileri avatar airondev avatar alao-abiodun avatar aptcoder avatar clish254 avatar dave-ok avatar davidalenoghena avatar dependabot[bot] avatar ericomartin avatar ihechiwilliams avatar lihemen avatar neymarjimoh avatar ochuwa-sophie avatar oscar-ekeyekwu avatar papa28x4 avatar piouson avatar reichx avatar simeon979 avatar simply-alliv avatar the-indigo avatar tonymj76 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

comment-microapi's Issues

[FEATURE REQUEST] Create Swagger documentation for "GET: /comments"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the GET: /comments endpoint. This endpoint will be used to get all comments of a particular reference id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the GET: /comments endpoint.

[FEATURE REQUEST]: Create validation middleware for validation rules

Is your feature request related to a problem? Please describe.

Various endpoints will need request data or parameters to be validated. This middleware when placed in a particular route and supplied validation rules should accept or reject with an appropriate response

Describe the solution you'd like

Implementation of validation middleware using Joi validation package

[FEATURE REQUEST] Create CONTRIBUTING.md file and update README accordingly.

Is your feature request related to a problem? Please describe.

The current Contributions.md file contains old endpoints and its also not documentation on how to contribute, which causes confusion due to its file name as a list of endpoints isn't a responsibility of such a file. The CONTRIBUTING.md file should contain documentation on how to contribute so as to be much more in line with the responsibility of such a file.

Describe the solution you'd like

  • Create a CONTRIBUTING.md file with documentation on contributing.
  • Delete the Contributions.md file as it will not be required anymore with the Swagger Documentation up and running.
  • Update the README.md file to direct contributors to the contributing file and also steps on how to view API documentation (via Swagger).

Describe alternatives you've considered

None.

Additional context

The Swagger Documentation will be the single source of truth when it comes to documentation on API endpoints. This will reduce errors and confusion.

[BUG] Fix API assertions tests for root endpoint

Describe the bug

#25 was merged incomplete, leading to CI errors
This should fix CI errors and complement the GET / tests

To Reproduce

Expected behavior

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

[FEATURE REQUEST] Create Swagger documentation for "GET: comment/{commentId}/reply/all"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the GET: comment/{commentId}/reply/all endpoint. This endpoint will be used to get all replies to a comment with a particular comment id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the GET: comment/{commentId}/reply/all endpoint.

[FEATURE REQUEST]Get all comments in order from the one with the most upvotes to the one with the least upvotes.

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
The most upvoted comments are likely to be the most interesting, there should be an option to get all comments in ordered according to to the number of upvotes.

Describe the solution you'd like

A clear and concise description of what you want to happen.
Write a controller that gets all comments including flagged comments from the db and then orders them according tho the number of upvotes.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.
The alternative is that the comments can be sorted in the frontend but our api should be able to return data in this order easily.

Additional context

Add any other context or screenshots about the feature request here.
I think i've explained everything to the best of my ability,please comment if there is any concern

[chore]: Document Endpoint & Response Format

Is your feature request related to a problem? Please describe.

This Document will be a guide to the contributors for them to know how to return their responses and routes.
And also aid easy documentation of the API Endpoints

Describe the solution you'd like

Swagger Documentation Tool for the API Documentation

Describe alternatives you've considered

Aternative Considered is Apiary

Additional context

None

[FEATURE REQUEST] - Add invalid route handler

Is your feature request related to a problem? Please describe.

There is no invalid route handler

Describe the solution you'd like

Create a catch-all route for non-existent endpoints. In other words a 404 route handler

Additional context

Currently, invalid routes crash the server because there is no default route handler

[FEATURE REQUEST] Create Swagger documentation for "GET: comments/refs/{refId}"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the GET: comments/refs/{refId} endpoint. This endpoint will be used to get all comments of a particular reference id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the GET: comments/refs/{refId} endpoint.

[BUG] comment model is not well reference to other model

Describe the bug

A clear and concise description of what the bug is.
The comment model is not referencing other models appropriately.

To Reproduce

Steps to reproduce the behavior:

  1. Go to controller
  2. Click on the comment.js file inside the controller
  3. Scroll down to see the schema of the model.
  4. see an error: Schema.Types.ObjectId.

Expected behavior

A clear and concise description of what you expected to happen.
It should be: mongoose.Schema.Types.ObjectId

Screenshots

If applicable, add screenshots to help explain your problem.
comment

Desktop (please complete the following information):

  • OS: [windows]
  • Browser [chrome]
  • Version 83.0.4103.116

Additional context

No

[FEATURE REQUEST] Switch to jest-mongodb for test database and refactor database code

Is your feature request related to a problem? Please describe.

@shelf/jest-mongodb includes setup, teardown and database in-memory management

Should resolve this nagging warning

image

Describe the solution you'd like

  • Add @shelf/jest-mongodb package #77
  • Refactor database code to switch between testing and production environments #77
  • Drop wait timeouts from existing tests #77

Describe alternatives you've considered

  • Using real cloud database for testing as in TEST_DB_URL from .env.example

Additional context

[FEATURE REQUEST]Users can flag off comments

Overview

  • Users can flag off comments
    This will update the comment as being flagged and the number of times a comment is being flagged off is shown which increases or decreases as the case may be

[FEATURE REQUEST] UPDATE COMMENTS

UPDATE COMMENTS

Controller and API endpoint for updating comments

Describe the solution you'd like

Authenticated user should be able to edit his/her comments and if possible edited comments should carry the label "edited"

Additional context

Edited comments should recognizable, by including an "edited" label

[FEATURE REQUEST] Create Swagger documentation for "DELETE: comment/delete/{commentId}"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the DELETE: comment/delete/{commentId} endpoint. This endpoint will be used to delete a comment with a particular comment id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the DELETE: comment/delete/{commentId} endpoint.

[FEATURE REQUEST]: Refactor DB connection and implement test setup/teardown

Is your feature request related to a problem? Please describe.

Currently almost every test suite adds a delay to compensate for the MongoDB connection. As the number of tests increase the time to run tests will become extreme. We also need to prepare the application to work with different DBs either test, development or production environments because at the moment the DB url is hardcoded and inflexible

Describe the solution you'd like

  • Move mongoDB connection out of the express app initialization and into main entry file
  • Modify DB connection url to use environment variables (something similar mentioned in #24)
  • Setup test setup/teardown to enable DB connection only at beginning of all tests and disconnection after all tests are done
  • Optionally, seed test DB with initial values that is used within test environment

[FEATURE REQUEST] Create Swagger documentation for "POST: comment/{commentId}/reply/create"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the POST: comment/{commentId}/reply/create endpoint. This endpoint will be used to create a reply to a comment with a particular comment id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the POST: comment/{commentId}/reply/create endpoint.

[FEATURE REQUEST]: Enforce uniform responses and error messages

Is your feature request related to a problem? Please describe.

Several contributors with different coding styles may end up sending responses in different formats.

Describe the solution you'd like

Create utility functions/middleware to ensure that all reponses and error messages are uniform

[FEATURE REQUEST] Create Swagger documentation for "PATCH: comment/flag/{commentId}"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the PATCH: comment/flag/{commentId} endpoint. This endpoint will be used to set the flagged status of a comment with a particular comment id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the PATCH: comment/flag/{commentId} endpoint.

[FEATURE REQUEST]: Setup CI/CD with Travis CI

Is your feature request related to a problem? Please describe.

To enable continuous testing and deployment of develop branch on a test

Describe the solution you'd like

  • Run lint and tests on CI on PR and on merge
  • Deploy develop branch to a test server on heroku

[FEATURE REQUEST] Create Swagger documentation for Comments API

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints.

Describe the solution you'd like

Create documentation for each comments endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation.

[FEATURE REQUEST] GET ALL COMMENTS ON A REPORT (INCLUDING FLAGGED COMMENTS)

GET ALL COMMENTS (ADMIN)

Write a controller method that returns all comments on a particular expense report including flagged comments for admin moderation

Describe the solution you'd like

Write a controller method and endpoint url that returns all comments on a particular expense report

Describe alternatives you've considered

Another controller method can be written that will return only un-flagged comments for frontend display

[FEATURE REQUEST] Create Swagger documentation for "PATCH: comment/vote/{commentId}"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the PATCH: comment/vote/{commentId} endpoint. This endpoint will be used to modify the votes of a comment with a particular comment id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the PATCH: comment/vote/{commentId} endpoint.

[FEATURE REQUEST] Create Swagger documentation for "PATCH: comment/edit/{commentId}"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the PATCH: comment/edit/{commentId} endpoint. This endpoint will be used to edit a comment with a particular comment id.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible responses.

Describe alternatives you've considered

None.

Additional context

For more information, see the Contribution documentation on the PATCH: comment/edit/{commentId} endpoint.

[FEAT]: Create Controller method to return all replies of a Comment

Is your feature request related to a problem? Please describe.

This feature will return all replies under a comment and return as json

Describe the solution you'd like

A controller method to implement the endpoint /comments/{commentId}/replies

Describe alternatives you've considered

Additional context

[chore]: Adding a well detailed pull request template for subsequent PRs

Overview

Every pull request before being being created should have a brief description about the entirety of the what the PR entails:

  • What the PR does?
    Summarize the main tasks handled by the PR
  • How should it be manually tested?
  • Any background context that's needed (e.g. an API KEY etc)
  • The related issue this PR is reflecting if any
  • Screenshots (where appropriate)

[FEATURE REQUEST]Get all comments in order from the one with the most upvotes the one with the least upvotes.

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
The most upvoted comments are likely to be the most interesting, there should be an option to get all comments in ordered according to to the number of upvotes.

Describe the solution you'd like

A clear and concise description of what you want to happen.
Write a controller that gets all comments including flagged comments from the db and then orders them according tho the number of upvotes.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.
The alternative is that the comments can be sorted in the frontend but our api should be able to return data in this order easily.

Additional context

Add any other context or screenshots about the feature request here.
I think i've explained everything to the best of my ability,please comment if there is any concern

[FEATURE REQUEST] GET ALL UNFLAGGED COMMENTS ON A REPORT

###GET ALL COMMENTS (UNFLAGGED)
Controller method that returns ony unflagged comments on a particular expense report for web display

###Solution
Write a controller method and endpoint URL that returns only unflagged comments on a particular expense report

Additional context

Add any other context or screenshots about the feature request here.

[chore]: Setup linting and test framework

To enable code consistency and possible CI integration, we need to setup linting and a test framework (e.g Jest)

What tasks need to be carried out?

  • Setup ESLint
  • Setup prettier for code formatting
  • Setup Jest testing framework
  • Initialize test

bug: Refractor of the API documentation

Describe the bug

Refractor of the swagger documentation of API

To Reproduce

Steps to reproduce the behavior:

  1. Change the file into multiple files
  2. Then we create the main file for the YAML definition
  3. Each of the files will reference the main file.

Expected behavior

To ease the teammates that will work on the API docs issue and to prevent breaking changes in code.

Screenshots

No

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Version 83.0.4103.116

Additional context

No

[FEATURE REQUEST] Add a test database for test env

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

  • When a test case is created that has to do with database manipulations ,the current database will be affected

Describe the solution you'd like

A clear and concise description of what you want to happen.

  • A new database for tests which will be used in test environments
    • create a new database for tests
    • add a new config file for handling the different parameters by environment
    • change the url in mongoose config to point at new test DB

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

[Test]: Write Test Cases for GET Requests

Is your feature request related to a problem? Please describe.

Code can break, and response not handled properly. To avoid code breaking on live, test cases need be passed and routes coverage be maximum

Describe the solution you'd like

Write test cases using jest for listed endpoints on the Documentation

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

No

[FEATURE REQUEST]controller to handle post requests for adding comments

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Users should be able to add comments.

Describe the solution you'd like

A clear and concise description of what you want to happen.
The controller will validate the request body and save the comment in the db.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered
This is a core feature so there is really no alternative.

Additional context

Add any other context or screenshots about the feature request here.

[FEATURE REQUEST] Get all the comment for specific reference id

U### Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Users should be able to get all comments for a particular referenceId (i.e user).

Describe the solution you'd like

A clear and concise description of what you want to happen.
A controller to get all comment for a specific reference Id
Endpoints: /comment/refs/:{refId}

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.
No alternative

Additional context

Add any other context or screenshots about the feature request here.
No

Time Duration to finish

50mins

[FEATURE REQUEST]use @hapi/joi for schema description and data validation

Is your feature request related to a problem? Please describe.

It is important to do validation of data from a user before persisting it in the db.Data validation can get very complex especially when dealing with multiple schemas like we are.

Describe the solution you'd like

@hapi/joi is a module that is used to define a schema or blueprint of Javascript objects. Once the schema is defined, you then can use Joi's handy methods that come bundled with it, to validate any other objects against the schema. In our case the req.body will be compared with a schema we describe using @hapi/joi. @hapi/joi will also create detailed error messages for us so we don't have to write error messages again and again for every case.

Describe alternatives you've considered

I've considered writing all the validation from scatch for all the schemas but this can get long and clutter our code.

Additional context

With @hapi/joi we can just describe a schema and compare it with data sent by a user every time a POST request is made.Joi will validate the data and create a detailed error message if any errors are found.

I'd like to work on this so please assign this to me if this issue is accepted.

[FEATURE REQUEST] Setup swagger-jsdoc and swagger-ui-express

Is your feature request related to a problem? Please describe.

I'd like to start adding documentation for the API but there is no setup for me to view the documentation I write via a route.

Describe the solution you'd like

Setup swagger-jsdoc and swagger-ui-express and integrate the swagger-ui through a route so that we can view the documentation we will be writing.

Describe alternatives you've considered

None

Additional context

None

[FEATURE REQUEST] Create Swagger Documentation for "POST: /comment/create"

Is your feature request related to a problem? Please describe.

Documentation is required so that consumers of the API have a clear idea of how the API works and what is expected of them when using the API and its endpoints. This documentation pertains to the POST: /comment/create endpoint. This endpoint will be used to save new comment coming from a particular report on the web.

Describe the solution you'd like

Create documentation for the endpoint, its method, the required body, the response body, and the other possible response.

Describe alternatives you've considered

None

Additional context

For more information, see the Contribution.md file.

[Test] Write Test Cases for POST and DELETE Comments

Is your feature request related to a problem? Please describe.

Tests for continuous integration

Describe the solution you'd like

  • POST /comments #77
  • POST /comments/{commentId}/replies #77
  • DELETE /comments/{commentId} #77
  • DELETE /comments/{commentId}/replies/{replyId} #77

Describe alternatives you've considered

Tests not included
  • GET /comments #47
  • GET /comments/refs/{refId} #47
  • GET /comments/{commentId}/replies #47
  • PATCH /comments/{commentId}
  • PATCH /comments/{commentId}/votes
  • PATCH /comments/{commentId}/votes
  • PATCH /comments/{commentId}/flag
  • PATCH /comments/{commentId}/replies/{replyId}
  • PATCH /comments/{commentId}/replies/{replyId}/votes
  • PATCH /comments/{commentId}/replies/{replyId}/flag

Additional context

Please assign me to this issue

[FEATURE REQUEST] Write test for the root endpoint

Is your feature request related to a problem? Please describe.

Initial test example for the root endpoint

Describe the solution you'd like

  • test GET /
  • test HTTP status
  • test JSON object returned

Describe alternatives you've considered

Additional context

I would submit a PR for this issue. Anyone using Jest first time can build on this

[BUG]

Fix readme description error

[FEATURE REQUEST] Endpoint to get all replies to a comment

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen.

  • There should be an endpoint to get all replies to a comment

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

Endpoint :

GET /comments/{commentId}/replies

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.