-
Notifications
You must be signed in to change notification settings - Fork 70
a2-nickborrello-nick-borrello #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements an expense tracker application as part of Assignment 2. The application transforms a basic Node.js starter template into a functional expense management system with create, read, and delete operations.
Key Changes:
- Refactored server to handle expense tracking with
/create,/update, and/deleteendpoints - Built a single-page application (SPA) with dynamic table rendering and inline editing
- Added server-side calculation of "days remaining" derived field based on expense due dates
- Updated styling with flexbox layout and custom color scheme
Reviewed changes
Copilot reviewed 6 out of 22 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| server.improved.js | Implements REST API endpoints for expense CRUD operations with derived field calculation |
| public/js/main.js | Frontend logic for expense management, table rendering, and server communication |
| public/index.html | HTML structure with form inputs and expense table |
| public/css/main.css | Styling with flexbox layout and custom theme |
| package.json | Updated metadata and mime dependency version |
| README.md | Project documentation replacing assignment instructions |
| node_modules/ | Added mime 2.6.0 dependency files |
Comments suppressed due to low confidence (1)
public/js/main.js:99
- Unused variable photo.
photo = document.querySelector("#expenseDate");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| appdata.push(dataString); | ||
| console.log("Added", appdata); | ||
| response.writeHead(200, "OK", { "Content-Type": "text/plain" }); | ||
| response.end("New contact posted"); |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message says "New contact posted" but this is an expense tracker application, not a contact manager. The message should say "New expense posted" or similar.
| response.end("New contact posted"); | |
| response.end("New expense posted"); |
| event.preventDefault() | ||
| const addToTable = function (expense) { | ||
| let expenseList = document.querySelector("tbody"); | ||
| let data = JSON.parse(expense); |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function addToTable is parsing JSON that was already stringified by JSON.stringify() in the server. This double serialization is inefficient. Consider storing the parsed object directly in appdata instead of stringifying it, or adjust the client-side code to handle the data structure appropriately.
| let data = JSON.parse(expense); | |
| let data = expense; |
| row.appendChild(cell); | ||
| } | ||
| const cell = document.createElement("td"); | ||
| cell.innerHTML='<input type="button" value="Delete" onclick="deleteRow(this)"/>'; |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deleteRow function is exposed globally via onclick="deleteRow(this)" in the HTML. This is not ideal for security and maintainability. Consider using event delegation or addEventListener instead of inline onclick handlers.
| cell.innerHTML='<input type="button" value="Delete" onclick="deleteRow(this)"/>'; | |
| const deleteBtn = document.createElement("input"); | |
| deleteBtn.type = "button"; | |
| deleteBtn.value = "Delete"; | |
| deleteBtn.addEventListener("click", function() { | |
| deleteRow(deleteBtn); | |
| }); | |
| cell.appendChild(deleteBtn); |
| expenseName: name.value, | ||
| expenseNumber: number.value, | ||
| expenseDate: dueDate.value, | ||
| }, |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon after the closing parenthesis of the request.on event handler.
| let dataIndex = 0; | ||
| request.on("data", function (data) { | ||
| dataIndex = data; | ||
| }) |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon after the closing brace of the request.on('data') event handler.
| }) | |
| }); |
|
|
||
| th, tr, ts { | ||
| text-align: center; | ||
| border: |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete CSS rule - the border property on line 40 has no value specified. This will cause a CSS syntax error.
| border: | |
| border: 1px solid #e1e1e1; |
| number = document.querySelector("#expenseNumber"), | ||
| photo = document.querySelector("#expenseDate"); |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable photo is declared but never used. It appears this should be named dueDate instead of photo based on the context (line 99 shows #expenseDate is the due date input).
| number = document.querySelector("#expenseNumber"), | |
| photo = document.querySelector("#expenseDate"); | |
| number = document.querySelector("#expenseNumber"); |
| document.getElementById('expenseList').deleteRow(i-1); | ||
|
|
||
| // Delete the row from the server | ||
| const reponse = await fetch("/delete", { |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable reponse.
| const reponse = await fetch("/delete", { | |
| await fetch("/delete", { |
| const name = document.querySelector("#expenseName"), | ||
| number = document.querySelector("#expenseNumber"), | ||
| photo = document.querySelector("#expenseDate"); |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable name.
| const name = document.querySelector("#expenseName"), | |
| number = document.querySelector("#expenseNumber"), | |
| photo = document.querySelector("#expenseDate"); |
| } No newline at end of file | ||
| window.onload = function () { | ||
| const name = document.querySelector("#expenseName"), | ||
| number = document.querySelector("#expenseNumber"), |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable number.
| number = document.querySelector("#expenseNumber"), |
No description provided.