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",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"prisma": "5.19.1"
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "5.19.1",
|
||||
"@prisma/client": "^5.20.0",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/jsonwebtoken": "^9.0.6",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.21.0",
|
||||
"jest": "^29.7.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"supertest": "^7.0.0"
|
||||
},
|
||||
"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
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "mysql"
|
||||
provider = "postgresql"
|
@ -9,7 +9,7 @@ generator client {
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
provider = "postgres"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
|
41
compose.yaml
41
compose.yaml
@ -1,9 +1,46 @@
|
||||
---
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
front-end:
|
||||
build: ./front_end
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "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:
|
||||
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();
|
||||
alert("Login successful:", data);
|
||||
//login();
|
||||
} catch (error) {
|
||||
console.error("Error during login:", error);
|
||||
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",
|
||||
element: <SignIn />,
|
||||
children: [
|
||||
{
|
||||
path: "profil",
|
||||
/* element: <ProtectedRoute element={<Profil />} />, */
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/register",
|
||||
|
Loading…
Reference in New Issue
Block a user