feat: implement MainForm component and set up routing; add user table schema and trigger in SQL
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
const router = express.Router();
|
||||
dotenv.config();
|
||||
24
backend/scheme.sql
Normal file
24
backend/scheme.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(100) NOT NULL,
|
||||
first_name VARCHAR(100) NOT NULL,
|
||||
last_name VARCHAR(100) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
unique_key CHAR(25) NOT NULL UNIQUE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Trigger zur automatischen Generierung eines 25‑stelligen Keys
|
||||
DELIMITER $
|
||||
|
||||
CREATE TRIGGER before_user_insert
|
||||
BEFORE INSERT ON users
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.unique_key = SUBSTRING(
|
||||
REPLACE(UUID(), '-', '')
|
||||
-- UUID = 32 Zeichen, wir nehmen 25 davon
|
||||
, 1, 25);
|
||||
END$
|
||||
|
||||
DELIMITER ;
|
||||
@@ -1,5 +1,8 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import defaultRouter from "./routes/default/frontend.route.js";
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT;
|
||||
@@ -9,6 +12,8 @@ app.use(cors());
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
app.use("/default", defaultRouter);
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.render("index");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user