Skip to content

Commit 043bc14

Browse files
committed
fix(frontend): refactor Nav into layout
feat(frontend): login page skeleton fix(server): refactor Prisma/JWT utils into `server/` directory
1 parent 3622f19 commit 043bc14

File tree

12 files changed

+575
-749
lines changed

12 files changed

+575
-749
lines changed

components/Layout.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
2-
<body class="bg-grayscale-300 text-grayscale-950">
2+
<div
3+
class="flex flex-col flex-grow h-screen bg-grayscale-300 text-grayscale-950"
4+
>
5+
<Nav />
36
<slot />
4-
</body>
7+
</div>
58
</template>
69

710
<script setup lang="ts">

components/home/Hero.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div
3-
class="flex h-full items-center justify-center flex-col gap-4 md:gap-8 pt-24"
3+
class="flex h-full items-center justify-center flex-col gap-4 md:gap-8"
44
>
55
<h1 class="text-4xl md:text-7xl font-black">Readconquista</h1>
66
<h3 class="text-lg md:text-3xl font-medium">

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
"typescript": "^5.3.3"
4747
},
4848
"license": "Zlib"
49-
}
49+
}

pages/index.vue

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
title="Readconquista"
44
description="Library card collection for Melbourne, AU"
55
>
6-
<Nav />
76
<Hero />
87
</Layout>
98
</template>

pages/login.vue

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<Layout title="Login | Readconquista" description="Login to Readconquista">
3+
<div
4+
class="flex h-full items-center justify-center flex-col gap-4 md:gap-8 pt-24"
5+
>
6+
<h2 class="text-xl md:text-2xl font-semibold">Login</h2>
7+
</div>
8+
</Layout>
9+
</template>
10+
11+
<script setup lang="ts">
12+
import { storeToRefs } from "pinia";
13+
14+
import { useAuthStore } from "~/utils/authStore";
15+
import { pinia } from "~/utils/pinia";
16+
17+
const { authenticated } = storeToRefs(useAuthStore(pinia));
18+
</script>

server/api/auth/login.post.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as argon2 from "argon2";
22
import { v4 } from "uuid";
33
import { z } from "zod";
44

5-
import db from "~/utils/db";
6-
import { generateTokens } from "~/utils/jwt";
7-
import { addRefreshToken } from "~/utils/refreshToken";
5+
import db from "~/server/utils/db";
6+
import { generateTokens } from "~/server/utils/jwt";
7+
import { addRefreshToken } from "~/server/utils/refreshToken";
88

99
const schema = z.object({
1010
username: z.string().min(3).optional(),

server/api/auth/register.post.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as argon2 from "argon2";
22
import { v4 } from "uuid";
33
import { z } from "zod";
44

5-
import db from "~/utils/db";
6-
import { generateTokens } from "~/utils/jwt";
7-
import { addRefreshToken } from "~/utils/refreshToken";
5+
import db from "~/server/utils/db";
6+
import { generateTokens } from "~/server/utils/jwt";
7+
import { addRefreshToken } from "~/server/utils/refreshToken";
88

99
const schema = z.object({
1010
username: z.string().min(3),

utils/db.ts server/utils/db.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { PrismaClient, type LibraryService } from "@prisma/client";
55

6-
import type { Library } from "./types/library";
6+
import type { Library } from "../../utils/types/library";
77

88
const prisma = new PrismaClient().$extends({
99
model: {

utils/jwt.ts server/utils/jwt.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import jwt from "jsonwebtoken";
33

44
import crypto from "node:crypto";
55

6-
const runtimeConfig = useRuntimeConfig();
7-
86
export function hashToken(token: string) {
97
return crypto.createHash("sha512").update(token).digest("hex");
108
}
119

1210
export function generateAccessToken(user: User): string {
11+
const runtimeConfig = useRuntimeConfig();
1312
return jwt.sign({ userId: user.id }, runtimeConfig.jwtAccessSecret, {
1413
expiresIn: "5m",
1514
});
1615
}
1716

1817
export function generateRefreshToken(user: User, jti: string) {
18+
const runtimeConfig = useRuntimeConfig();
1919
return jwt.sign(
2020
{
2121
userId: user.id,
File renamed without changes.

utils/pinia.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { createPinia } from "pinia";
2+
3+
export const pinia = createPinia();

0 commit comments

Comments
 (0)