Files
apophis-fastify/docs/examples/minimal.ts
T

27 lines
585 B
TypeScript
Raw Normal View History

import Fastify from 'fastify'
import apophisPlugin from 'apophis-fastify'
const fastify = Fastify()
// APOPHIS auto-registers @fastify/swagger
await fastify.register(apophisPlugin, {})
fastify.get('/health', {
schema: {
'x-category': 'observer',
'x-ensures': ['status:200'],
response: {
200: {
type: 'object',
properties: { status: { type: 'string' } }
}
}
}
}, async () => ({ status: 'ok' }))
await fastify.ready()
// Run contract tests
const result = await fastify.apophis.contract({ depth: 'quick' })
console.log(result.summary)