Skip to content

Issues with Fastify + TypeBox #5302

Closed Answered by sinclairzx81
hrishikesh-k asked this question in Q&A
Discussion options

You must be logged in to vote

@hrishikesh-k Hi. I'm not familiar with @fastify/cookie plugin, however I did find a few issues with the signup.ts module. I've updated your repro script pasted these updates below.

The main two issues I saw were:

  1. Using explicit generics on the route which were overriding the TypeProvider on api
  2. No 400 status code type (for { msg: ... } on either generics or schema)

I've added comments where applicable.

import type { FastifyTypebox } from '~/types/global.ts'
import { RouteSignupReqBody, RouteSignupRes } from '~/types/global.ts' // No need to import TRouteSignupReqBody, TRouteSignupRes
import { Type } from '@sinclair/typebox'

export default function (api: FastifyTypebox) {
  api.post('…

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@hrishikesh-k
Comment options

@mcollina
Comment options

@sinclairzx81
Comment options

Answer selected by hrishikesh-k
@hrishikesh-k
Comment options

@sinclairzx81
Comment options

@hrishikesh-k
Comment options

@sinclairzx81
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants