created backend to create lottery entries manually
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import env from "dotenv";
|
||||
import { query, loginAdmin, getTableData } from "./services/database.js";
|
||||
import {
|
||||
query,
|
||||
loginAdmin,
|
||||
getTableData,
|
||||
createEntry,
|
||||
} from "./services/database.js";
|
||||
import { generateToken, authenticate } from "./services/tokenService.js";
|
||||
env.config();
|
||||
const app = express();
|
||||
@@ -30,7 +35,16 @@ app.get("/table-data", authenticate, async (req, res) => {
|
||||
if (result.success) {
|
||||
res.status(200).json(result.data);
|
||||
} else {
|
||||
res.status(500);
|
||||
res.status(500).json({ success: false });
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/create-entry", async (req, res) => {
|
||||
const result = await createEntry(req.body);
|
||||
if (result.success) {
|
||||
res.status(201).json({ success: true });
|
||||
} else {
|
||||
res.status(400).json({ success: false });
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user