fix: jsonResponse doesn't assume ZodObject
Close #60
Checks if json response is a zod json object schema or not by checking the zod schema definition typeName. It's a bit of a weird feature that I found after doing some digging here https://github.com/colinhacks/zod/pull/523
I also haven't tested this yet. If someone can explain how to do that, would appreciate it.
Interesting, I wonder if this will maintain safe types
I also haven't tested this yet. If someone can explain how to do that, would appreciate it.
I think you can add a test to the example app in this repo (but those tests don't currently run in CI?)
Got around this by adding a addOkStatus: false in my route spec. Will use this for now and look into testing the solution or other options.
import { createWithRouteSpec } from 'nextlove'
import withDb from './with-db.ts'
import withOAuthAccessToken from './with-oauth-access-token.ts'
export const withRouteSpec = createWithRouteSpec({
apiName: 'Fake Template',
productionServerUrl: 'https://example.com',
shouldValidateGetRequestBody: false,
globalMiddlewares: [withDb],
authMiddlewareMap: {
oauth_access_token: withOAuthAccessToken,
},
addOkStatus: false,
} as const)
export default withRouteSpec