Skip to content

A note application utilizing Express.js backend to write, store, retrieve, and delete notes.

Notifications You must be signed in to change notification settings

nhanng19/notepad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note Taker

Installation

The application will be invoked by using the following command:

npm start

Use following port to view the application:

http://localhost:3001/

CONSOLE DEMO

USER DEMO

HEROKU DEPLOYMENT LINK

The Process

To satisfy the criteria, we had to:

  • Install inquirer package
  • Install path package
  • Install express package
  • Refractor CSS file to give HTML nootbook theme
  • Code server.js to initialize applications' backend

Specific functions of server.js:

Create new note along with new object and alert terminal

app.post("/api/notes", (req, res) => {
    let savedNotes = JSON.parse(fs.readFileSync("./db/db.json", "utf8"));
    let newNote = req.body;
    let uniqueID = (savedNotes.length).toString();
    newNote.id = uniqueID;
    savedNotes.push(newNote);

    fs.writeFileSync("./db/db.json", JSON.stringify(savedNotes));
    console.log("A new note has been saved: ", newNote);
    res.json(savedNotes);
})

Delte note along with object and alert terminal

app.delete("/api/notes/:id", (req, res) => {
    let savedNotes = JSON.parse(fs.readFileSync("./db/db.json", "utf8"));
    let noteID = req.params.id;
    let newID = 0;
    console.log(`Deleting note with ID ${noteID}`);
    savedNotes = savedNotes.filter(currentNote => {
        return currentNote.id != noteID;
    })
    
    for (currentNote of savedNotes) {
        currentNote.id = newID.toString();
        newID++;
    }

    fs.writeFileSync("./db/db.json", JSON.stringify(savedNotes));
    res.json(savedNotes);
})

The Result

After dynamically coding our backend application using Express.js along with refractoring CSS and HTML, we were able to provide a fully functional fullstack application that allows our client to write, store, retrieve, and delete notes.

This project was uploaded to GitHub at the following repository link: https://github.com/nhanng19/notepad

Deployed Web Application link: https://expressnotepad.herokuapp.com/

Releases

No releases published

Packages

No packages published