(
req: FastifyRequest<{
Body: ITrackHandlerPayload | DeprecatedPostEventPayload;
}>,
reply: FastifyReply,
)
| 6 | import type { FastifyReply, FastifyRequest } from 'fastify'; |
| 7 | |
| 8 | export async function clientHook( |
| 9 | req: FastifyRequest<{ |
| 10 | Body: ITrackHandlerPayload | DeprecatedPostEventPayload; |
| 11 | }>, |
| 12 | reply: FastifyReply, |
| 13 | ) { |
| 14 | try { |
| 15 | const client = await validateSdkRequest(req); |
| 16 | req.client = client; |
| 17 | } catch (error) { |
| 18 | if (error instanceof SdkAuthError) { |
| 19 | req.log.warn({ err: error }, 'Invalid SDK request'); |
| 20 | return reply.status(401).send(error.message); |
| 21 | } |
| 22 | |
| 23 | req.log.error({ err: error }, 'Invalid SDK request'); |
| 24 | return reply.status(500).send('Internal server error'); |
| 25 | } |
| 26 | } |
nothing calls this directly
no test coverage detected