feat: bootstrap OSDB full-stack skeleton (story #01)
- Go backend: Echo v4 + pgxpool + embedded golang-migrate; health endpoints at /health and /api/v1/health; TDD health handler (httptest) - Vue 3 frontend: Vite + TypeScript + Pinia + vue-router + Tailwind CSS v4; TDD HelloWorld component (@vue/test-utils + jsdom + vitest) - Infra: docker-compose postgres:16 with env-interpolated credentials; Makefile with dev-db health-wait loop, migrate-up/down, run, test, fmt - embed.FS migrations at backend/migrations/ (000001 no-op baseline) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createPinia } from 'pinia'
|
||||
import HelloWorld from './HelloWorld.vue'
|
||||
|
||||
// Stub fetch so the component's onMounted health call doesn't hit the network.
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ status: 'ok' }),
|
||||
}))
|
||||
})
|
||||
|
||||
describe('HelloWorld', () => {
|
||||
it('renders the OSDB greeting', async () => {
|
||||
const wrapper = mount(HelloWorld, {
|
||||
global: {
|
||||
plugins: [createPinia()],
|
||||
},
|
||||
})
|
||||
expect(wrapper.text()).toContain('Hello, OSDB!')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getHealth } from '../api/health'
|
||||
|
||||
const backendStatus = ref<string | null>(null)
|
||||
const backendError = ref<string | null>(null)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const data = await getHealth()
|
||||
backendStatus.value = data.status
|
||||
} catch (err) {
|
||||
backendError.value = err instanceof Error ? err.message : 'unknown error'
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="flex flex-col items-center justify-center min-h-screen gap-4">
|
||||
<h1 class="text-4xl font-bold">Hello, OSDB!</h1>
|
||||
|
||||
<div v-if="backendStatus" class="text-green-600">
|
||||
Backend: {{ backendStatus }}
|
||||
</div>
|
||||
<div v-else-if="backendError" class="text-red-600">
|
||||
Backend unreachable: {{ backendError }}
|
||||
</div>
|
||||
<div v-else class="text-gray-400">
|
||||
Checking backend…
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
Reference in New Issue
Block a user