typescript
import type { Static } from "@sinclair/typebox"
import type { FastifyReply, FastifyRequest } from "fastify"
import { Type } from "@sinclair/typebox"
import type { PluginFastifyInstance } from "@raclettejs/types"
const ParamsSchema = Type.Object({
_id: Type.String(),
})
type Params = Static<typeof ParamsSchema>
export default (fastify: PluginFastifyInstance) => {
const handler = async (
req: FastifyRequest<{
Params: Params
}>,
reply: FastifyReply,
) => {
try {
/* YOUR BUSINESS LOGIC */
} catch (err: any) {
fastify.log.error(err.message)
return reply.internalServerError(err.message)
}
}
return {
handler,
onRequest: [fastify.authenticate],
config: {
type: dataUpdate,
broadcastChannels: ["exampleUpdated"],
},
schema: {
summary: "Example example get Route",
description: "Example example get Route",
tags: ["myApp/example"],
body: exampleBaseSchema,
},
}
}