I want to use @fastify/cookies plugin, i setup like in docs, but my types still doesn't have types like setCookie, cookie etc.
I use nx monorepo and i want to use it in my library which expose modules to core app. Firstly i though that it's related with this architecture, but when i check in app (where I register plugin) i try to use it in app controller, it still doesn't work.
I use pnpm 8.6.7, nx integrated repos architecture (so there is one node_modules and package.json at root folder and all apps and libs use it)
import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { AppModule } from './app/app.module';
import fastifyCookie from '@fastify/cookie';
const globalPrefix = 'api';
async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
await app.register(fastifyCookie, {
secret:'COOKIES_SIGNATURE',
});
...
}
bootstrap();
And in controller at the same app:
import { Controller, Get, Req, Res } from '@nestjs/common'
import { AppService } from './app.service'
import { FastifyReply, FastifyRequest } from 'fastify'
import fastifyCookie from '@fastify/cookie';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
test(@Req() request: FastifyRequest, @Res({ passthrough: true }) res: FastifyReply){
request.cookies // Property 'setCookies' does not exist on type 'FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<...>>'.ts(2339)
// res.
}
}