@samveys/fastify
Dari packages/fastify/README.md di repository framework.
Halaman ini belum diterjemahkan. Kamu sedang membaca versi bahasa Inggris.
HTTP driver for @samveys/http on Fastify. Fastify owns the server
lifecycle; the Samveys kernel owns every request: routing, bodies, limits, compression and errors.
Fastify never parses a body or matches a route, so an app behaves the same on node, fastify and hono.
fastify is a peer dependency: install the version you want next to this package.
Use it
import { createHttpServer } from '@samveys/http'
import { fastify } from '@samveys/fastify'
const server = await createHttpServer(app, { driver: fastify(), host: '0.0.0.0', port: 3000 })
await server.listen()Options
fastify({ configure }) runs configure(instance) on the Fastify instance before it starts listening, for
plugins, hooks or decorators. It cannot change how requests are handled: every request ends in the kernel.
import { fastify } from '@samveys/fastify'
export const driver = fastify({
configure: (instance) => {
instance.addHook('onClose', async () => {})
},
})
console.log(driver.name, driver.streaming)driver.native is the Fastify instance once listening (undefined before). WebSocket upgrades reach the
http:upgrade listener through the same driver.upgrade(kernel) hook the node driver uses.
Conformance
The driver passes the whole @samveys/http/conformance suite, and a shared sample app returns identical
statuses, bodies and key headers on node, fastify and hono.