Reputation: 97
Hi i am trying to register the @fastify/cookie plugin to my nestjs backend but i have an error and i don't know why because in previous code i was doing the same thinks and was working , i don't know if versions changed or if there is a new way of registering plugins with nestJs -> Fastify
here is my code
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import fastifyCookie from '@fastify/cookie';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(),
);
await app.register(fastifyCookie, { secret: '' });
await app.listen(3005);
}
bootstrap();
and i am getting
Argument of type 'FastifyCookie' is not assignable to parameter of type 'FastifyPluginCallback<FastifyCookieOptions, RawServerDefault, FastifyTypeProviderDefault, FastifyBaseLogger> | FastifyPluginAsync<...> | Promise<...> | Promise<...>'
here are the versions i am using
Upvotes: 5
Views: 1950
Reputation: 1
You should match the version of the installed fastify
package to the version used in @nestjs/platform-fastify
.
platform-fastify
version fixed: npm i @nestjs/platform-fastify --save-exact
node_modules/@nestjs/platform-fastify/package.json
"fastify": "4.28.0",
npm i [email protected] --save-exact
By doing these steps I was able to make the @fastify/cookie
plugin registered.
My versions after the fix:
"@nestjs/core": "^10.0.0"
"@nestjs/platform-fastify": "10.3.10"
"fastify": "4.28.0"
"@fastify/cookie": "^9.3.1"
Upvotes: 0