late fix
This commit is contained in:
22
index.php
22
index.php
@@ -40,7 +40,7 @@ $app->use("/", function (array &$req, Response $res) {
|
||||
* Home
|
||||
*/
|
||||
$app->get("/", function (array $req, Response $res) use ($db) {
|
||||
$res->json(["message" => "",
|
||||
$res->json(["message" => "Die Einkaufsliste des Don",
|
||||
"name" => "Shopping List",
|
||||
"authors" => "Simon Bock, Johannes Kantz & Malte Schulze Hobeling"]);
|
||||
});
|
||||
@@ -55,10 +55,6 @@ $app->get("/user", function (array $req, Response $res) {
|
||||
$res->json(["status" => HTTP_STATUS_CODE::FORBIDDEN, "message" => "You are not logged in. Goto '/login' to login"]);
|
||||
}
|
||||
});
|
||||
$app->get("/user/:id", function (array $req, Response $res) use ($db) {
|
||||
$db->select("utente", ["username" => $req["id"]]);
|
||||
$res->send("user " . $req["params"]["id"]);
|
||||
});
|
||||
$app->post("/signup", function (array $req, Response $res) use ($db) {
|
||||
$newUsername = $req["body"]["username"];
|
||||
$newPassword = $req["body"]["password"];
|
||||
@@ -116,7 +112,12 @@ $app->route("/ingredient")
|
||||
$app->route("/ingredient/:id")
|
||||
->get(function (array $req, Response $res) use ($db) {
|
||||
$id = $req["params"]["id"];
|
||||
$ingredient = $db->select("ingredienti", ["id" => $id])[0];
|
||||
$query = $db->select("ingredienti", ["id" => $id]);
|
||||
if(count($query) < 1){
|
||||
$res->json(["message" => "Item does not exists"]);
|
||||
return;
|
||||
}
|
||||
$ingredient = $query[0];
|
||||
$res->json(["data" => $ingredient]);
|
||||
})
|
||||
->put(function (array $req, Response $res) use ($db) {
|
||||
@@ -172,8 +173,13 @@ $app->route("/unit")
|
||||
$app->route("/unit/:id")
|
||||
->get(function (array $req, Response $res) use ($db) {
|
||||
$id = $req["params"]["id"];
|
||||
$ingredient = $db->select("folla", ["id" => $id])[0];
|
||||
$res->json(["data" => $ingredient]);
|
||||
$query = $db->select("folla", ["id" => $id]);
|
||||
if(count($query) < 1){
|
||||
$res->json(["message" => "Unit does not exists"]);
|
||||
return;
|
||||
}
|
||||
$unit = $query[0];
|
||||
$res->json(["data" => $unit]);
|
||||
})
|
||||
->put(function (array $req, Response $res) use ($db) {
|
||||
$id = $req["params"]["id"];
|
||||
|
||||
Reference in New Issue
Block a user