diff --git a/index.html b/index.html
index fba7f47..0ab9b12 100644
--- a/index.html
+++ b/index.html
@@ -20,6 +20,8 @@
None
+ Login
+ Register
diff --git a/login.html b/login.html
index 38d6620..ff3d510 100644
--- a/login.html
+++ b/login.html
@@ -3,11 +3,17 @@
LOGIN
+ Game
-
+
+
+
+
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index e6ed90d..44bd9a8 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -8,7 +8,8 @@ datasource db {
}
model User {
- id Int @id @default(autoincrement())
- email String @unique
- name String?
+ id Int @id @default(autoincrement())
+ email String @unique
+ name String?
+ password String
}
diff --git a/register.html b/register.html
new file mode 100644
index 0000000..7a595bc
--- /dev/null
+++ b/register.html
@@ -0,0 +1,20 @@
+
+
+
+
+ REGISTER
+ Game
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/server.ts b/server.ts
index acd670a..1885679 100644
--- a/server.ts
+++ b/server.ts
@@ -1,11 +1,23 @@
import { Hono } from "hono";
import { upgradeWebSocket, websocket } from "hono/bun";
+import { DatabaseService } from "@/services/database-service";
const app = new Hono();
app.get("/", async (c) => {
+ const database = new DatabaseService();
+ await database.getClient().user.create({
+ data: {
+ email: "rosati5.matteo@gmail.com",
+ name: "Matteo",
+ },
+ });
+
+ const users = await database.getClient().user.findMany();
+
return c.json({
message: "ok",
+ users: users,
});
});
diff --git a/src/main.css b/src/main.css
index 1d7771c..709741a 100644
--- a/src/main.css
+++ b/src/main.css
@@ -35,6 +35,14 @@ body {
padding: 5px;
}
+#info > a:link,
+#info > a:visited,
+#info > a:hover,
+#info > a:active {
+ color: #ffffff;
+ text-decoration: underline;
+}
+
.info-box {
margin: 10px;
padding: 10px;
diff --git a/src/services/auth-service.ts b/src/services/auth-service.ts
index 820eff4..3d9771b 100644
--- a/src/services/auth-service.ts
+++ b/src/services/auth-service.ts
@@ -1,3 +1,5 @@
+import { User } from "@/orm/generated/prisma/browser";
+
export class AuthService {
public login = (user: string, password: string): string => {
return "token";
@@ -6,4 +8,8 @@ export class AuthService {
public logout = (): boolean => {
return true;
};
+
+ public getUser(): User | null {
+ return null;
+ }
}
diff --git a/src/services/database-service.ts b/src/services/database-service.ts
new file mode 100644
index 0000000..af763d8
--- /dev/null
+++ b/src/services/database-service.ts
@@ -0,0 +1,17 @@
+import { PrismaPg } from "@prisma/adapter-pg";
+import { PrismaClient } from "@/orm/generated/prisma";
+
+export class DatabaseService {
+ private prisma: PrismaClient;
+
+ constructor() {
+ const databaseUrl = `${Bun.env.DATABASE_URL}`;
+ const adapter = new PrismaPg({ connectionString: databaseUrl });
+
+ this.prisma = new PrismaClient({ adapter });
+ }
+
+ public getClient(): PrismaClient {
+ return this.prisma;
+ }
+}
diff --git a/tsconfig.json b/tsconfig.json
index 921f4a7..b2632f4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -20,9 +20,9 @@
"baseUrl": ".",
"paths": {
- "@/*": ["./src/*"]
- }
+ "@/*": ["./src/*", "./server.ts"],
+ },
},
- "include": ["src/**/*.ts", "src/**/*.tsx"],
- "exclude": ["node_modules", "dist"]
+ "include": ["src/**/*.ts", "src/**/*.tsx", "./server.ts"],
+ "exclude": ["node_modules", "dist"],
}
diff --git a/vite.config.ts b/vite.config.ts
index 105b67f..fde5c65 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -4,9 +4,7 @@ import { resolve } from "path";
import FullReload from "vite-plugin-full-reload";
export default defineConfig({
- plugins: [
- FullReload(["*.html"], { delay: 200 }),
- ],
+ plugins: [FullReload(["*.html"], { delay: 200 })],
server: {
watch: {
usePolling: true,
@@ -24,10 +22,6 @@ export default defineConfig({
build: {
chunkSizeWarningLimit: 1600,
rollupOptions: {
- input: {
- main: resolve(__dirname, "index.html"),
- login: resolve(__dirname, "login.html"),
- },
output: {
manualChunks(id) {
if (id.includes("node_modules")) {