Argument of type 'FastifyCookie' is not assignable to parameter of type 'FastifyPluginCallback<FastifyCookieOptions> | FastifyPluginAsync<FastifyCookieOptions> | Promise<...> | Promise<...>'. #13219
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
error TS2345: Argument of type 'FastifyCookie' is not assignable to parameter of type 'FastifyPluginCallback | FastifyPluginAsync | Promise<...> | Promise<...>'.
Type 'FastifyCookie' is not assignable to type 'FastifyPluginCallback'.
Types of parameters 'instance' and 'instance' are incompatible.
Type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse, FastifyBaseLogger, FastifyTypeProviderDefault>' is missing the following properties from type 'FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse, FastifyBaseLogger, FastifyTypeProviderDefault>': serializeCookie, parseCookie, signCookie, unsignCookie
main.ts:
import fastifyCookie from '@fastify/cookie';
import { NestFactory } from '@nestjs/core';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { ZodExceptionFilter } from '@shared/filters/zod-exception';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(
AppModule,
new FastifyAdapter(),
);
await app.register(fastifyCookie, {
secret: process.env.SECRET_KEY,
hook: 'onRequest',
});
app.useGlobalFilters(new ZodExceptionFilter());
await app.listen(4000);
}
bootstrap();
controller:
@post(':poll_id/votes')
async createVote(
@param() { poll_id }: CreateVoteDTOParam,
@Body() { poll_option_id }: CreateVoteDTOBody,
@Req() request: FastifyRequest,
@res({ passthrough: true }) response: FastifyReply,
): Promise {
const voteOnPollBody = createVoteSchemaBody.parse({
poll_option_id: String(poll_option_id),
});
}
I already try put the fastifyCookie as any, works, but the cookie is not working as should be, the request.cookies is empty. Someone can help me?
Minimum reproduction code
https://github.com/dev-mariana/nlw-expert-node
Steps to reproduce
No response
Expected behavior
I would like to generate a cookie in my app by post request.
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
No response
Packages versions
"dependencies": {
"@fastify/cookie": "^9.3.1",
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/platform-fastify": "^10.3.3",
"@prisma/client": "^5.9.1",
"fastify": "^4.26.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
"zod": "^3.22.4"
},
Node.js version
20.10.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: