Skip to content

Commit

Permalink
docs: contributing
Browse files Browse the repository at this point in the history
Signed-off-by: Ourchitecture <[email protected]>
  • Loading branch information
ourchitectureio committed Sep 29, 2023
1 parent 9f9fe4f commit 32e0d80
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ourchitectureio
22 changes: 22 additions & 0 deletions .github/CONTRIBUTING.md
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"._
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ignoreWords:
- MADR
- msedge
- nvmrc
- ourchitectureio
- pnpmrc
- testid
import: []
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const express = require('express')

const clearCompleted = require('./clearCompleted')
const createTodo = require('./createTodo')
const removeTodo = require('./removeTodo')
const saveAll = require('./saveAll')
const toggleCompleted = require('./toggleCompleted')

const router = express.Router()

router.post('/clear-completed', clearCompleted)
router.post('/create', createTodo)
router.post('/toggle-completed', toggleCompleted)
router.post('/save-all', saveAll)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ block content
input(type="submit",name="button-save",value="Save")
if viewModel.hasTodos
footer(data-testid="footer")
input(type="submit",name="button-clear-completed",value="Clear completed")
input(type="submit",formaction="/todos/clear-completed",name="button-clear-completed",value="Clear completed")

0 comments on commit 32e0d80

Please sign in to comment.