Skip to content

Homework areas for improvement #1

@hynesy23

Description

@hynesy23

"test": "echo \"Error: no test specified\" && exit 1"

If your application has no tests you can just delete this bit

//const { htmlRouter, apiRouter } = require("./routes/delete");

Delete any unused, commented out code

//const { getAllNotes, saveNotes, deleteNotes, getNotesById } = require("../controllers/apiControllers");

This would have worked fine instead of line 5 - why comment it out?

const path = require("path");

No need for path or fs here, can be removed

//api/notes -> GET (all notes from db.json)

More commented out code that can be removed

const database = require("../../db/db.json");

const BASE_URL = "http://localhost:3000/api/notes";

You're not using databse of BASE_URL here, can be removed

fs.readFileSync(path.join(__dirname, "../../db/db.json"), "utf-8")

Would be nice to see th fs methods extracted out to their own modules

htmlRouter.get("/", renderIndexPage);

Currently, if you hit an endpoint that is anything other than 'notes', the app breaks. You should add a star here (htmlRouter.get("/*", renderIndexPage); ) as a catch all, so if you enter an endpoint that is not /notes it will take you back to the landing/index page

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions