Initial commit: Add project files
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { api } from '@/shared/api/client'
|
||||
import { requestSchema, responseSchema, type Request } from './schema'
|
||||
|
||||
export async function execute(request: Request) {
|
||||
const body = requestSchema.parse(request)
|
||||
const response = await api.post('/__ROUTE__', body)
|
||||
return responseSchema.parse(response.data)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
// Server state belongs to TanStack Query. Pinia is limited to session/UI preferences.
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1>__FEATURE__</h1>
|
||||
<p>Contract-first scaffold. Complete Zod request/response schemas before enabling the route.</p>
|
||||
</main>
|
||||
</template>
|
||||
@@ -0,0 +1,5 @@
|
||||
import { useMutation, useQuery } from '@tanstack/vue-query'
|
||||
import { execute } from './api'
|
||||
|
||||
export const featureKeys = { all: ['__FEATURE__'] as const }
|
||||
export function useExecute() { return useMutation({ mutationFn: execute }) }
|
||||
@@ -0,0 +1,8 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { responseSchema } from './schema'
|
||||
|
||||
describe('__FEATURE__ response contract', () => {
|
||||
it('fails closed for an unapproved empty payload', () => {
|
||||
expect(responseSchema.safeParse({}).success).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const requestSchema = z.object({ /* approved contract */ })
|
||||
export const responseSchema = z.object({ /* runtime trust boundary */ })
|
||||
export type Request = z.infer<typeof requestSchema>
|
||||
export type Response = z.infer<typeof responseSchema>
|
||||
Reference in New Issue
Block a user