Initial commit
Signed-off-by: mikesir87 <mikesir87@gmail.com> Imported from dockersamples/101-tutorial, removed other languages for now, and replaced PWD references with Docker Desktop.
This commit is contained in:
13
app/src/routes/addItem.js
Normal file
13
app/src/routes/addItem.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const db = require('../persistence');
|
||||
const uuid = require('uuid/v4');
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const item = {
|
||||
id: uuid(),
|
||||
name: req.body.name,
|
||||
completed: false,
|
||||
};
|
||||
|
||||
await db.storeItem(item);
|
||||
res.send(item);
|
||||
};
|
6
app/src/routes/deleteItem.js
Normal file
6
app/src/routes/deleteItem.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const db = require('../persistence');
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
await db.removeItem(req.params.id);
|
||||
res.sendStatus(200);
|
||||
};
|
6
app/src/routes/getItems.js
Normal file
6
app/src/routes/getItems.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const db = require('../persistence');
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
const items = await db.getItems();
|
||||
res.send(items);
|
||||
};
|
10
app/src/routes/updateItem.js
Normal file
10
app/src/routes/updateItem.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const db = require('../persistence');
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
await db.updateItem(req.params.id, {
|
||||
name: req.body.name,
|
||||
completed: req.body.completed,
|
||||
});
|
||||
const item = await db.getItem(req.params.id);
|
||||
res.send(item);
|
||||
};
|
Reference in New Issue
Block a user