-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ourchitecture <[email protected]>
- Loading branch information
1 parent
9f9fe4f
commit 32e0d80
Showing
6 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @ourchitectureio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Contributing | ||
|
||
👋🏽 Hello, and thank you for your interest in contributing. | ||
|
||
## Getting started | ||
|
||
### Prerequisites | ||
|
||
- [NodeJS LTS](https://nodejs.org/en) | ||
- [`pnpm`](https://pnpm.io/installation) | ||
|
||
### Testing the project works as expected | ||
|
||
1. Install project dependencies with the command `pnpm install` | ||
2. Run the tests with the command `pnpm test` | ||
|
||
### Start the project | ||
|
||
1. Run the command `pnpm --filter @our-todo/html-and-expressjs start`. | ||
2. Browse to the website <http://localhost:3000> | ||
|
||
_\*Specify a different port number by setting the environment variable "PORT"._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ ignoreWords: | |
- MADR | ||
- msedge | ||
- nvmrc | ||
- ourchitectureio | ||
- pnpmrc | ||
- testid | ||
import: [] |
26 changes: 26 additions & 0 deletions
26
src/experiments/todo/implementations/html-and-expressjs/routes/todos/clearCompleted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { TODO_STATUS } = require('./models') | ||
|
||
const requestHandler = function (req, res, next) { | ||
if (!req.session.todos) { | ||
req.session.todos = [] | ||
} | ||
|
||
const originalTodos = req.session.todos | ||
|
||
const completedTodoIds = req.body['completed-todo-id'] | ||
? Array.isArray(req.body['completed-todo-id']) | ||
? req.body['completed-todo-id'] | ||
: [req.body['completed-todo-id']] | ||
: [] | ||
|
||
const updatedTodos = originalTodos.filter((todo) => { | ||
const isCompleted = completedTodoIds.includes(todo.id) | ||
return !isCompleted | ||
}) | ||
|
||
req.session.todos = updatedTodos | ||
|
||
res.redirect('/') | ||
} | ||
|
||
module.exports = requestHandler |
2 changes: 2 additions & 0 deletions
2
src/experiments/todo/implementations/html-and-expressjs/routes/todos/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters