This commit is contained in:
parent
5f71dcd028
commit
8f6d6d68a8
10
back-end/Dockerfile
Normal file
10
back-end/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM docker.io/oven/bun:1.1-slim
|
||||||
|
WORKDIR /app/
|
||||||
|
COPY package.json bun.lockb .
|
||||||
|
RUN bun install
|
||||||
|
COPY api/ api/
|
||||||
|
COPY index.js .
|
||||||
|
COPY prisma/ prisma/
|
||||||
|
COPY .env .
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["bun", "index.js"]
|
Binary file not shown.
@ -3,18 +3,18 @@
|
|||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest",
|
"@types/bun": "latest"
|
||||||
"prisma": "5.19.1"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "5.19.1",
|
"@prisma/client": "^5.20.0",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/jsonwebtoken": "^9.0.6",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.21.0",
|
"express": "^4.21.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
|
"jsonwebtoken": "^9.0.2",
|
||||||
"supertest": "^7.0.0"
|
"supertest": "^7.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
-- CreateTable
|
|
||||||
CREATE TABLE `User` (
|
|
||||||
`id` INTEGER NOT NULL,
|
|
||||||
`username` VARCHAR(191) NOT NULL,
|
|
||||||
`pswd` VARCHAR(191) NOT NULL,
|
|
||||||
`email` VARCHAR(191) NOT NULL,
|
|
||||||
|
|
||||||
UNIQUE INDEX `User_id_key`(`id`),
|
|
||||||
UNIQUE INDEX `User_email_key`(`email`)
|
|
||||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
@ -1,2 +0,0 @@
|
|||||||
-- AlterTable
|
|
||||||
ALTER TABLE `User` MODIFY `id` INTEGER NOT NULL AUTO_INCREMENT;
|
|
13
back-end/prisma/migrations/20241010152336_init/migration.sql
Normal file
13
back-end/prisma/migrations/20241010152336_init/migration.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "User" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"username" TEXT NOT NULL,
|
||||||
|
"pswd" TEXT NOT NULL,
|
||||||
|
"email" TEXT NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
@ -1,3 +1,3 @@
|
|||||||
# Please do not edit this file manually
|
# Please do not edit this file manually
|
||||||
# It should be added in your version-control system (i.e. Git)
|
# It should be added in your version-control system (i.e. Git)
|
||||||
provider = "mysql"
|
provider = "postgresql"
|
@ -9,7 +9,7 @@ generator client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "mysql"
|
provider = "postgres"
|
||||||
url = env("DATABASE_URL")
|
url = env("DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
41
compose.yaml
41
compose.yaml
@ -1,9 +1,46 @@
|
|||||||
---
|
---
|
||||||
services:
|
services:
|
||||||
app:
|
front-end:
|
||||||
build: .
|
build: ./front_end
|
||||||
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8000:5173"
|
- "8000:5173"
|
||||||
|
environment:
|
||||||
|
- PROD_URL=${PROD_URL}
|
||||||
|
depends_on:
|
||||||
|
- back-end
|
||||||
|
|
||||||
|
back-end:
|
||||||
|
build: ./back-end
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- "bunx prisma migrate deploy && bunx prisma generate && bun index.js"
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB
|
||||||
|
- POSTGRES_USER
|
||||||
|
- POSTGRES_PASSWORD
|
||||||
|
- POSTGRES_HOST=db
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- db
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: "valkey/valkey:7"
|
image: "valkey/valkey:7"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: "postgres:17"
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB
|
||||||
|
- POSTGRES_USER
|
||||||
|
- POSTGRES_PASSWORD
|
||||||
|
volumes:
|
||||||
|
- db:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db:
|
||||||
|
3
front_end/src/files/Profil.jsx
Normal file
3
front_end/src/files/Profil.jsx
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function Profil() {
|
||||||
|
return <h1>profil page</h1>;
|
||||||
|
}
|
@ -25,6 +25,7 @@ export function SignIn() {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
alert("Login successful:", data);
|
alert("Login successful:", data);
|
||||||
|
//login();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during login:", error);
|
console.error("Error during login:", error);
|
||||||
alert("Error during login: " + error.message);
|
alert("Error during login: " + error.message);
|
||||||
|
25
front_end/src/services/AuthContext.jsx
Normal file
25
front_end/src/services/AuthContext.jsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { createContext, useContext, useState } from "react";
|
||||||
|
|
||||||
|
const AuthContext = createContext();
|
||||||
|
|
||||||
|
export function AuthProvider({ children }) {
|
||||||
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
||||||
|
|
||||||
|
const login = () => {
|
||||||
|
setIsAuthenticated(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const logout = () => {
|
||||||
|
setIsAuthenticated(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AuthContext.Provider value={{ isAuthenticated, login, logout }}>
|
||||||
|
{children}
|
||||||
|
</AuthContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAuth() {
|
||||||
|
return useContext(AuthContext);
|
||||||
|
}
|
@ -21,6 +21,12 @@ export const router = createBrowserRouter([
|
|||||||
{
|
{
|
||||||
path: "/sign-in",
|
path: "/sign-in",
|
||||||
element: <SignIn />,
|
element: <SignIn />,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "profil",
|
||||||
|
/* element: <ProtectedRoute element={<Profil />} />, */
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/register",
|
path: "/register",
|
||||||
|
Loading…
Reference in New Issue
Block a user