View the source on GitHub or Glitch.
I created this microservice as a requirement for my freeCodeCamp Information Security and Quality Assurance Certification, using Node.js, Express, MongoDB, Chai, and Helmet. The above front end API tests also use Bootstrap, jQuery, and highlight.js.
You can read the functional tests I wrote on
GitHub
or
Glitch. To run the tests yourself, create a MongoDB database, fork/remix this
project, create a .env
file with
DB="{your MongoDB URI}"
and NODE_ENV="test"
,
start the server, and look at the server console logs.
This project fulfills the following user stories:
"PHP 4.2.0"
even
though it isn't as a security measure.
title
to /api/books
to
add a book and returned will be the object with the
title
and a unique _id
.
/api/books
to retrieve an aray of all
books containing title
, _id
, &
commentcount
.
/api/books/{_id}
to retrieve a single
object of a book containing title
, _id
,
& an array of comments
(empty array if no comments
present).
comment
to
/api/books/{_id}
to add a comment to a book and returned
will be the books object similar to get
/api/books/{_id}
.
/api/books/{_id}
to delete a book
from the collection. Returned will be
"delete successful"
if successful.
"no book exists"
message.
/api/books
to
delete all books in the database. Returned will be
"complete delete successful"
if successful.