feat: add entry removal and row saving functionality, enhance admin components with localization
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
loginAdmin,
|
||||
getTableData,
|
||||
createEntry,
|
||||
removeEntries,
|
||||
saveRow,
|
||||
} from "./services/database.js";
|
||||
import { generateToken, authenticate } from "./services/tokenService.js";
|
||||
env.config();
|
||||
@@ -30,6 +32,22 @@ app.post("/lose", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// !!!!!!! AUTHORISATION HINZUFÜGEN - DENN GEHT NICHT !!!!!!!!
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app.get("/table-data", authenticate, async (req, res) => {
|
||||
const result = await getTableData();
|
||||
if (result.success) {
|
||||
@@ -48,6 +66,24 @@ app.post("/create-entry", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.delete("/remove-entries", async (req, res) => {
|
||||
const result = await removeEntries(req.body.losnummern);
|
||||
if (result) {
|
||||
res.status(200).json({ success: true });
|
||||
} else {
|
||||
res.status(400).json({ success: false });
|
||||
}
|
||||
});
|
||||
|
||||
app.put("/save-row", async (req, res) => {
|
||||
const result = await saveRow(req.body);
|
||||
if (result.success) {
|
||||
res.status(200).json({ success: true });
|
||||
} else {
|
||||
res.status(400).json({ success: false });
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/login", async (req, res) => {
|
||||
const { username, password } = req.body;
|
||||
const result = await loginAdmin(username, password);
|
||||
|
Reference in New Issue
Block a user