feat(api): create template

Add template table to the database
Create controller function to check if user has template, and create it
in the database
Made universal jwt.Claims of user data retrieval function
This commit is contained in:
Leons Aleksandrovs
2025-07-09 23:19:31 +03:00
parent 3376043428
commit 938c9a66e5
10 changed files with 209 additions and 14 deletions
+15 -2
View File
@@ -1,7 +1,20 @@
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
name TEXT NOT NULL,
password TEXT NOT NULL,
"name" TEXT NOT NULL,
"password" TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS "templates" (
"id" SERIAL PRIMARY KEY,
"user_id" INTEGER NOT NULL,
"name" VARCHAR(50) NOT NULL UNIQUE,
"template" TEXT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_user
FOREIGN KEY (user_id)
REFERENCES users (id)
ON DELETE CASCADE
);