Skip to content

Commit 35e30a6

Browse files
committed
feat: add CORS support and database setup functionality
- Added @fastify/cors plugin to backend for handling CORS requests. - Updated backend Fastify plugin registration to include CORS configuration. - Introduced a new Setup view for database configuration in the frontend. - Implemented database service to check status and setup database. - Created a Pinia store for managing database state and actions. - Added form validation for database setup using VeeValidate and Zod. - Integrated alert components for displaying success and error messages. - Updated routing to include a setup route and navigation guards. - Enhanced i18n support by adding setup localization. - Updated dependencies for @vueuse/core, reka-ui, and others.
1 parent 71647f3 commit 35e30a6

29 files changed

+950
-19
lines changed

package-lock.json

Lines changed: 37 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@fastify/cookie": "^11.0.2",
15+
"@fastify/cors": "^11.0.1",
1516
"@lucia-auth/adapter-drizzle": "^1.1.0",
1617
"@node-rs/argon2": "^2.0.2",
1718
"arctic": "^3.7.0",

services/backend/src/fastify/plugins/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import { FastifyInstance } from 'fastify'
22
import fastifyFavicon from 'fastify-favicon'
3+
import fastifyCors from '@fastify/cors'
34

45
export const registerFastifyPlugins = async (server: FastifyInstance): Promise<void> => {
6+
// Register CORS plugin
7+
await server.register(fastifyCors, {
8+
origin: [
9+
'http://localhost:5173', // Vite dev server
10+
'http://localhost:3000', // Frontend production (if served from same port)
11+
'http://localhost:4173', // Vite preview
12+
],
13+
credentials: true,
14+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
15+
})
16+
517
// Register favicon plugin
618
await server.register(fastifyFavicon, {
719
path: '../shared/public/img',

services/frontend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"@tailwindcss/vite": "^4.1.7",
1818
"@tanstack/vue-table": "^8.21.3",
1919
"@vee-validate/zod": "^4.15.0",
20-
"@vueuse/core": "^13.2.0",
20+
"@vueuse/core": "^13.3.0",
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",
2323
"lucide-vue-next": "^0.511.0",
2424
"pinia": "^3.0.2",
25-
"reka-ui": "^2.2.1",
25+
"reka-ui": "^2.3.0",
2626
"tailwind-merge": "^3.3.0",
2727
"tailwindcss-animate": "^1.0.7",
2828
"vee-validate": "^4.15.0",

services/frontend/src/App.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,18 @@
55
</template>
66

77
<script setup lang="ts">
8+
import { onMounted } from 'vue'
89
import { RouterView } from 'vue-router'
10+
import { useDatabaseStore } from '@/stores/database'
11+
12+
const databaseStore = useDatabaseStore()
13+
14+
// Initialize database status check on app startup
15+
onMounted(async () => {
16+
try {
17+
await databaseStore.checkDatabaseStatus(true)
18+
} catch (error) {
19+
console.warn('Failed to check database status on app startup:', error)
20+
}
21+
})
922
</script>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
3+
import { cn } from '@/lib/utils'
4+
import { type AlertVariants, alertVariants } from '.'
5+
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
variant?: AlertVariants['variant']
9+
}>()
10+
</script>
11+
12+
<template>
13+
<div
14+
data-slot="alert"
15+
:class="cn(alertVariants({ variant }), props.class)"
16+
role="alert"
17+
>
18+
<slot />
19+
</div>
20+
</template>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
3+
import { cn } from '@/lib/utils'
4+
5+
const props = defineProps<{
6+
class?: HTMLAttributes['class']
7+
}>()
8+
</script>
9+
10+
<template>
11+
<div
12+
data-slot="alert-description"
13+
:class="cn('text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed', props.class)"
14+
>
15+
<slot />
16+
</div>
17+
</template>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
3+
import { cn } from '@/lib/utils'
4+
5+
const props = defineProps<{
6+
class?: HTMLAttributes['class']
7+
}>()
8+
</script>
9+
10+
<template>
11+
<div
12+
data-slot="alert-title"
13+
:class="cn('col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight', props.class)"
14+
>
15+
<slot />
16+
</div>
17+
</template>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { cva, type VariantProps } from 'class-variance-authority'
2+
3+
export { default as Alert } from './Alert.vue'
4+
export { default as AlertDescription } from './AlertDescription.vue'
5+
export { default as AlertTitle } from './AlertTitle.vue'
6+
7+
export const alertVariants = cva(
8+
'relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
9+
{
10+
variants: {
11+
variant: {
12+
default: 'bg-card text-card-foreground',
13+
destructive:
14+
'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
15+
},
16+
},
17+
defaultVariants: {
18+
variant: 'default',
19+
},
20+
},
21+
)
22+
23+
export type AlertVariants = VariantProps<typeof alertVariants>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script setup lang="ts">
2+
import type { SelectRootEmits, SelectRootProps } from 'reka-ui'
3+
import { SelectRoot, useForwardPropsEmits } from 'reka-ui'
4+
5+
const props = defineProps<SelectRootProps>()
6+
const emits = defineEmits<SelectRootEmits>()
7+
8+
const forwarded = useForwardPropsEmits(props, emits)
9+
</script>
10+
11+
<template>
12+
<SelectRoot
13+
data-slot="select"
14+
v-bind="forwarded"
15+
>
16+
<slot />
17+
</SelectRoot>
18+
</template>

0 commit comments

Comments
 (0)