A simple note-taking application that utilizes Node.js and Express.js
View the application here.
View the repository on GitHub
In this unit, we will create our own server-side APIs using the Express.js framework. Express is the most widely used Node.js server framework. It will allow us to quickly and easily establish our API routes and associated HTTP request methods.
Routing is how we design our server to handle responses when a client makes a request at a specific endpoint, or URL. We learned how to make GET requests from the client-side in a previous unit. Now we will learn how those requests are handled on the server-side. Our server will listen for a specific type of request at a specific endpoint and when it hears that request, it will respond accordingly.
We will also learn the HTTP POST request method to submit data to our server.
-
http
-
Express.js
-
Routing
-
Postman
-
HTTP POST requests
-
Express.static()
- To create an application that can be used to write, save, and delete notes.
- To have the application use an express backend and save and retrieve note data from a JSON file.
- To build the backend and connect it with the frontend which has already been created.
- Create the following HTML routes:
-
GET
/notes
- Should return thenotes.html
file. -
GET
*
- Should return theindex.html
file
-
Create a
db.json
file on the backend of the application that will be used to store and retrieve notes using thefs
module. -
Create the following API routes:
-
GET
/api/notes
- Should read thedb.json
file and return all saved notes as JSON. -
POST
/api/notes
- Should receive a new note to save on the request body, add it to thedb.json
file, and then return the new note to the client. -
DELETE
/api/notes/:id
- Should receive a query parameter containing the id of a note to delete. This means you'll need to find a way to give each note a uniqueid
when it's saved. In order to delete a note, you'll need to read all notes from thedb.json
file, remove the note with the givenid
property, and then rewrite the notes to thedb.json
file.
AS A user, I want to be able to write and save notes
I WANT to be able to delete notes I've written before
SO THAT I can organize my thoughts and keep track of tasks I need to complete
For users that need to keep track of a lot of information, it's easy to forget or be unable to recall something important. Being able to take persistent notes allows users to have written information available when needed.
Postman was used to check the GET
, POST
, and DELETE
requests.
Application should allow users to create and save notes.
Application should allow users to view previously saved notes.
Application should allow users to delete previously saved notes.
I tried to deploy the application to Heroku, but the URL is not loading and returns: "Application error." With the hope that I must have skipped a step when setting up the app, I deleted the application and started over. I again created a new app and followed the following directions. Even after taking these steps to deploy, the application URL still did not load.
Express JS Crash Course Heroku Deploy App Instructions
Dana Smooke
MIT
© 2021 Trilogy Education Services, LLC, a 2U, Inc. brand. Confidential and Proprietary. All Rights Reserved.