Skip to content

Commit 9d95af7

Browse files
committed
fixed branching problem!
1 parent 695203b commit 9d95af7

File tree

17 files changed

+3983
-4
lines changed

17 files changed

+3983
-4
lines changed

week3/homework/package-lock.json

Lines changed: 1851 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

week3/homework/package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
{
2-
"name": "hyf-node-week-3-homework",
3-
"version": "1.0.0",
4-
"description": "HackYourFuture Node.js Week 3 - Homework",
2+
"name": "hyf-node-week-3-todo",
3+
"version": "1.0.1",
4+
"description": "HackYourFuture Node.js Week 3 - To-Do App",
55
"repository": "https://github.com/HackYourFuture/nodejs.git",
66
"main": "src/index.js",
77
"author": "George Sapkin",
88
"license": "MIT",
9+
"scripts": {
10+
"start": "node src/index"
11+
},
12+
"dependencies": {
13+
"express": "^4.16.2",
14+
"uuid": "^3.2.1"
15+
},
916
"devDependencies": {
1017
"eslint": "^4.2.0",
1118
"eslint-config-standard": "^11.0.0",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
function clearTodos(todo, request, response) {
4+
todo.clearList()
5+
.then(() => {
6+
response.status(204);
7+
response.end();
8+
})
9+
.catch(({ message }) => {
10+
response.status(500);
11+
response.json({ error: message });
12+
});
13+
};
14+
15+
module.exports = clearTodos;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
const deserializeTodo = require('./deserializeTodo');
4+
5+
function createTodo(todo, request, response) {
6+
deserializeTodo(request, response)
7+
.then(({ description }) => todo.create(description))
8+
.then(todo => {
9+
response.status(201);
10+
response.json({ todo });
11+
})
12+
.catch(({ message }) => {
13+
response.status(500);
14+
response.json({ error: message });
15+
});
16+
};
17+
18+
module.exports = createTodo;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
function deleteTodo(todo, request, response) {
4+
const id = request.params.id;
5+
6+
todo.delete_(id)
7+
.then(() => {
8+
response.status(204);
9+
response.end();
10+
})
11+
.catch(({ message }) => {
12+
response.status(500);
13+
response.json({ error: message });
14+
});
15+
};
16+
17+
module.exports = deleteTodo;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
async function deserializeTodo(request) {
4+
const { todo } = request.body;
5+
if (todo == null)
6+
throw new Error('todo not set');
7+
8+
if (todo.description != null)
9+
todo.description = todo.description.trim();
10+
11+
if (todo.description == null || todo.description.length === 0)
12+
throw new Error('description not set');
13+
14+
return todo;
15+
};
16+
17+
module.exports = deserializeTodo;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
// CRUD actions
4+
module.exports = {
5+
createTodo: require('./createTodo'),
6+
readTodos: require('./readTodos'),
7+
updateTodo: require('./updateTodo'),
8+
deleteTodo: require('./deleteTodo'),
9+
readTodo: require('./readTodo'),
10+
clearTodos: require('./clearTodos')
11+
};

week3/homework/src/actions/markAsDone.js

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
function readTodo(todo, request, response) {
4+
const id = request.params.id;
5+
todo.read(id)
6+
.then(todos => {
7+
response.json({ todos });
8+
response.end();
9+
})
10+
.catch(({ message }) => {
11+
response.status(500);
12+
response.json({ error: message });
13+
});
14+
};
15+
16+
module.exports = readTodo;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
function readTodos(todo, request, response) {
4+
todo.read()
5+
.then(todos => {
6+
response.json({ todos });
7+
response.end();
8+
})
9+
.catch(({ message }) => {
10+
response.status(500);
11+
response.json({ error: message });
12+
});
13+
};
14+
15+
module.exports = readTodos;

0 commit comments

Comments
 (0)