Added richText and allowComments to customForms. It declares which fields has richText and which fields allows comments. This will be handy later for validations and also for the front end to render proper components for that.
Created model Comment. It saves a comment related to a field of a document
Better .env
Better gitignore organization
Removed old code
Revisited some documents API endpoints
Added new db-apis: Document.listGeneralComments( query ) and Comment.getAll(query), Comment.create(comment),Comment.resolve(query)
Added 4 new API endpoints
URI
Description
Auth
GET /api/v1/documents/:id/comments
Retrieves a list of comments of the documents. Available queryStrings - field and ids
-
POST /api/v1/documents/:id/comments
Creates a new comment in a document. The request body requires 2 fields: field and comment. The field is part of the fields of customForm. First, during a POST request, it validates if the field is part of the allowComments array of the customForm of the document. If not, it throws an Exception. If everything is ok, the comment is saved
authenticated
PUT /api/v1/documents/:id/update/:field
Updates the content of a field of a document. There is only one possible addition: a mark labeled as a comment
-
PUT /:id/comments/:idComment/resolve
Resolves a comment of a document. This only sets the value true to the field resolved of a comment. Only the author of the document can do this
authenticated & must be the author
Updated API documentation
Note 1: A test revision might be needed
Note 2: I might play around with mocha-steps cause I am having some issues with a POST and GET test.. Sometimes I need the POST to end properly before the GET and right now it does it job but a few times it fails.
richText
andallowComments
tocustomForms
. It declares which fields has richText and which fields allows comments. This will be handy later for validations and also for the front end to render proper components for that.Comment
. It saves a comment related to a field of a documentold
codeDocument.listGeneralComments( query )
andComment.getAll(query)
,Comment.create(comment)
,Comment.resolve(query)
GET /api/v1/documents/:id/comments
field
andids
POST /api/v1/documents/:id/comments
field
andcomment
. Thefield
is part of the fields of customForm. First, during a POST request, it validates if thefield
is part of theallowComments
array of the customForm of the document. If not, it throws an Exception. If everything is ok, the comment is savedPUT /api/v1/documents/:id/update/:field
PUT /:id/comments/:idComment/resolve
true
to the fieldresolved
of a comment. Only the author of the document can do thisNote 1: A test revision might be needed Note 2: I might play around with mocha-steps cause I am having some issues with a POST and GET test.. Sometimes I need the POST to end properly before the GET and right now it does it job but a few times it fails.