-
Notifications
You must be signed in to change notification settings - Fork 631
Pull Request for docker/multi-container to compared and implemented the both #65
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?
Changes from 7 commits
3bf1410
b6a2bdd
1fb179f
4561baf
6a0e441
cdb900d
7efce3d
63182c0
6a5cd9f
39257a4
00f0a45
59c1d91
6c28f0d
49715d4
f9a82f2
0decdfc
73b60af
aff63f2
5bb96b9
0f4ebe1
4b94ac9
230ca91
e81aea0
e8c0cd0
ca81aac
caa4512
fd42c1e
f936d1a
1d66e3d
9f02363
ceee602
2e9e711
10e194b
1daab53
02b63ce
719d6cc
c656ad7
51936e9
df7d469
6c9ee8e
358335a
a5c1834
a434a68
46b652c
69c6da8
d713ccf
f4f82e0
a011d52
378c9b7
028e973
f01f7ab
be47549
649d387
8c10a18
5c0f60e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: NodeJS with Webpack | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [18.x, 20.x, 22.x] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
|
|
||
| - name: Build | ||
| run: | | ||
| npm install | ||
| npx webpack | ||
|
Comment on lines
+1
to
+29
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| // Enhanced configuration: supports environment-based MongoDB URIs for flexibility and security | ||
| const mongoProdURI = process.env.MONGO_PROD_URI || 'mongodb://todo-database:27017/todoapp'; | ||
|
|
||
| module.exports = { | ||
| mongoProdURI: 'mongodb://todo-database:27017/todoapp', | ||
| mongoProdURI, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,5 +30,24 @@ router.post('/todo/destroy', async (req, res) => { | |
| res.redirect('/'); | ||
| }); | ||
|
|
||
| // POST - Edit todo item | ||
| router.post('/todo/edit', async (req, res) => { | ||
| const taskKey = req.body._key; | ||
| const newTask = req.body.task; | ||
| await Todo.findByIdAndUpdate(taskKey, { task: newTask }); | ||
| res.redirect('/'); | ||
| }); | ||
|
|
||
| // POST - Toggle completion status | ||
| router.post('/todo/toggle', async (req, res) => { | ||
| const taskKey = req.body._key; | ||
| const todo = await Todo.findById(taskKey); | ||
| if (todo) { | ||
| todo.completed = !todo.completed; | ||
| await todo.save(); | ||
| } | ||
| res.redirect('/'); | ||
| }); | ||
|
Comment on lines
+82
to
+164
|
||
|
|
||
|
|
||
| module.exports = router; | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -42,24 +42,39 @@ | |||||
| <div class="row"> | ||||||
| <div class="col-12"> | ||||||
| <% if(Object.keys(tasks).length> 0) { %> | ||||||
| <ul class="nav flex-column"> | ||||||
| <ul class="nav flex-column" role="list" aria-label="Todo list"> | ||||||
| <% tasks.forEach(todo=> { %> | ||||||
| <li class="nav-item"> | ||||||
| <div class="d-flex justify-content-between py-1"> | ||||||
| <div class="d-flex flex-row"> | ||||||
| <div> | ||||||
| <%= todo.task %> | ||||||
| <p class="text-muted"><small> | ||||||
| <%= moment(todo.created_at).fromNow() %> | ||||||
| </small></p> | ||||||
| <li class="nav-item" role="listitem"> | ||||||
|
||||||
| <li class="nav-item" role="listitem"> | |
| <li class="nav-item"> |
Copilot
AI
Dec 26, 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 checkbox has 'onchange="this.form.submit()"' which will cause a traditional form submission and page reload. However, there's also an AJAX handler set up in the script section (lines 94-109) that's meant to handle the submission via AJAX. These two approaches conflict - the traditional form submit will execute before the AJAX handler can preventDefault. Remove the inline onchange attribute to let the AJAX handler manage the submission.
| <input type="checkbox" name="completed" onchange="this.form.submit()" <%= todo.completed ? 'checked' : '' %> aria-label="Mark task as <%= todo.completed ? 'incomplete' : 'completed' %>"> | |
| <input type="checkbox" name="completed" <%= todo.completed ? 'checked' : '' %> aria-label="Mark task as <%= todo.completed ? 'incomplete' : 'completed' %>"> |
Copilot
AI
Dec 26, 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 inline onclick handler 'onclick="document.getElementById('edit-form-<%= todo._id %>').style.display='block';return false;"' contains unescaped single quotes within the EJS template output, which will break the JavaScript string. The todo._id and 'block' values need proper escaping or the attribute should use double quotes with escaped inner quotes.
| <a href="#" class="text-info mr-2" onclick="document.getElementById('edit-form-<%= todo._id %>').style.display='block';return false;" aria-label="Edit task"> | |
| <a href="#" class="text-info mr-2" onclick="document.getElementById("edit-form-<%= todo._id %>").style.display='block';return false;" aria-label="Edit task"> |
Copilot
AI
Dec 26, 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.
Similar to line 64, this inline onclick handler has the same quote escaping issue. The JavaScript 'this.parentElement.style.display='none'' contains unescaped quotes that will break the attribute.
| <button type="button" class="btn btn-secondary btn-sm" onclick="this.parentElement.style.display='none';return false;" aria-label="Cancel edit">Cancel</button> | |
| <button type="button" class="btn btn-secondary btn-sm" onclick='this.parentElement.style.display="none";return false;' aria-label="Cancel edit">Cancel</button> |
Copilot
AI
Dec 26, 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.
Using 'href="javascript:;"' for the delete link is an outdated pattern. A better approach would be to use 'href="#"' with 'event.preventDefault()' in a proper click handler, or use a button element with type="button" which is more semantically correct for an action that doesn't navigate.
| <a href="javascript:;" onclick="this.children[0].submit()" class="text-danger" aria-label="Delete task"> | |
| <a href="#" onclick="this.children[0].submit();return false;" class="text-danger" aria-label="Delete task"> |
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 npm install command runs in the repository root, but package.json is located in the 'app/' subdirectory. This will fail because there's no package.json in the root. The workflow should change to the app directory before running npm install.