To run, download the package and npm i node. Then: node server.js .
Here I've made a straightforward app that can be used for taking notes. The app is is made in Node and Express, and leverages the mongoose module to handle much of the API functionality. The data is stored on MongoDB's cloud service Atlas. I will use Postman here to demonstrate the endpoints.
I will mention that I have provided error handling for most of the functions. I do not show that here just to save space, but stuffice it to say that most of the wrong inputs a user could put in have an appropriate error response.
Onto showing the API endpoints!
POST: Every note creation has a unique id associated with it, given to use by default by mongoose.
GET: get-all returns all of our notes.
GET: We can retrieve any particular note with the noteId.
GET: The search function works by finding any matching keywords within the note contents, not the Id.
DELETE: Finally, we can delete by a particular note Id.
TODO Currently, I am working on two further functionalities:
1.) Refactoring the POST function so that it can either take in a single {note: String} JSON object (see my model file) or an array of multiple notes: i.e.: {["batch": {"note1": "first"}, {"note2": "second"}, ..., {"note3": "third"}]} . Getting mongoose to properly parse that object has been challenging. I can get the array itself to pass, but not its contents.
2.) Similarly, refactoring the DELETE function to delete an array of Ids, such as {[{"note":"id",...,"note":"id"}]}.
Further goals:
The next logical step is to of course connect this back end with a front end. Given the current tech in the stack, React seems like a clear choice here. Additionally, unit testing would be a good addition, even for a small project.