Skip to content

This is a simple Note Taker application that allows users to add, view saved notes and also delete the notes if the user don't need that note anymore. This application uses an express backend and save and retrieve note data from a JSON file.

License

Notifications You must be signed in to change notification settings

siennameow/note-taker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note Taker

License: MIT

Description 📝

This is a simple Note Taker application that allows users to add, view saved notes and also delete the notes if the user don't need that note anymore. This application uses an express backend and save and retrieve note data from a JSON file.

Deployed Application : https://note-taker-platinum.herokuapp.com/

Table of Contents 📖

Application Preview ⭐

Demo

Note Taker

Application Preview:

Main Page Note Page
Screen Shot 2022-04-27 at 7 02 06 PM Screen Shot 2022-04-27 at 7 02 18 PM

Features 📋

⚡️ Express.js to build server
⚡️ fs(File System) module to read and write from 'db.json' file.
⚡️ path module to Joins the specified paths into one
⚡️ deployed on heroku

Code Snippet 💻

JavaScript

API route DELETE to receive a query parameter that contains the id of a note to delete. It reads all notes from the db.json file, remove the note with the given id property, and then rewrite the notes to the db.json file.

app.delete('/api/notes/:id', (req, res) => {
  
  fs.readFile('./db/db.json', 'utf8', (err, data) => {
    if (err) throw err;
    let notes = JSON.parse(data);
    notes.forEach(function(thisNote, i) {              
      if (thisNote.id === req.params.id) {
        
          notes.splice(i, 1)            
      }
})

API route POST receive a new note to save on the request body, add it to the db.json file, and then return the new note to the client.

app.post('/api/notes', (req, res) => {
  fs.readFile('./db/db.json', 'utf8', (err, data) => {

    if (err) throw err;
    var notes = JSON.parse(data);
    let addNote = req.body;
    addNote.id = uuid();
    notes.push(addNote);

    fs.writeFile('./db/db.json', JSON.stringify(notes), (err, data) => {
      if (err) throw err;
      res.json(addNote);
      console.info('Successfully updated notes!')
    });
  }); 
});

Installation 🗳

  • Download or clone repository to use this application on local machine.
  • Node.js is required to run the application
  • To install necessary dependencies, run the following command :

npm i

Usage 💡

After installation :

  • Run node server.js in terminal to start. It will show a comment "This will start localhost server on PORT 3001."

  • Open browser and type http://localhost:3001/ to run this application on your local machine.

You can also check the Deployed Live Application : https://note-taker-platinum.herokuapp.com/

Technologies 🔧

License 📜

License: MIT MIT License

Copyright (c) 2022 Sienna Li

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contribution 👩🏻‍💻

If you would like to contribute to this project reach out to me. Contact Information can be found below or by clicking on the Questions link provided in the Table of Contents.

Questions ❓

📩 If you have any question, email me here at : lihexuan1@gmail.com
:octocat: My Github page is siennameow

Credits 🙌

Thanks to the following people who helped me in this project:

  • Jerome Chenette
  • Manuel Nunes
  • Vince Lee

About

This is a simple Note Taker application that allows users to add, view saved notes and also delete the notes if the user don't need that note anymore. This application uses an express backend and save and retrieve note data from a JSON file.

Topics

Resources

License

Stars

Watchers

Forks