I dont import/install fastify-formbody in any place of my project, but I got the following error:
(node:31444) [FST_MODULE_DEP_FASTIFY-FORMBODY] FastifyWarning.fastify-formbody: fastify-formbody has been deprecated. Use @fastify/[email protected] instead.
(Use `node --trace-warnings ...` to show where the warning was created)
Its prob a import from another lib.
Install the libs with the following versions and try to run the code.
My package.json file:
"dependencies": {
"@fastify/compress": "^5.0.0",
"@fastify/cors": "^7.0.0",
"@fastify/helmet": "^8.1.0",
"@fastify/request-context": "^3.0.0",
"@fastify/static": "5.0.2",
"@fastify/swagger": "^6.1.0",
"@nestjs/axios": "^0.0.8",
"@nestjs/common": "^8.4.6",
"@nestjs/config": "^2.0.1",
"@nestjs/core": "^8.4.6",
"@nestjs/platform-fastify": "^8.4.6",
"@nestjs/swagger": "^5.2.1",
"@nestjs/terminus": "^8.0.6",
"@newrelic/winston-enricher": "^3.1.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"cli-color": "^2.0.2",
"fastify": "3.29.0",
"lodash": "^4.17.21",
"newrelic": "^8.13.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.5",
"winston": "^3.7.2"
},
"devDependencies": {
"@commitlint/cli": "^17.0.1",
"@commitlint/config-conventional": "^17.0.0",
"@compodoc/compodoc": "^1.1.19",
"@nestjs/cli": "^8.2.6",
"@nestjs/schematics": "^8.0.11",
"@nestjs/testing": "^8.4.5",
"@types/cli-color": "^2.0.2",
"@types/jest": "^27.5.1",
"@types/lodash": "^4.14.182",
"@types/newrelic": "^7.0.3",
"@types/node": "^17.0.36",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"commitizen": "^4.2.4",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^8.0.1",
"is-ci": "^3.0.1",
"jest": "^27.5.1",
"lint-staged": "^12.4.3",
"prettier": "^2.6.2",
"sonarqube-scanner": "^2.8.1",
"source-map-support": "^0.5.21",
"supertest": "^6.2.3",
"ts-jest": "^27.1.5",
"ts-loader": "^9.3.0",
"ts-node": "^10.8.0",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.7.2"
},
require('newrelic');
import compression from '@fastify/compress';
import cors from '@fastify/cors';
import helmet from '@fastify/helmet';
import { fastifyRequestContextPlugin } from '@fastify/request-context';
import {
ClassSerializerInterceptor,
INestApplication,
Logger,
LogLevel,
ValidationPipe,
VersioningType,
} from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { useContainer } from 'class-validator';
import fastify from 'fastify';
import { AppModule } from './app.module';
import {
fastifyRequestIdHookHandler,
HttpExceptionFilter,
REQUEST_ID_HEADER_KEY,
WinstonLogger,
} from './common';
import {
PROJECT_DESCRIPTION,
PROJECT_NAME,
PROJECT_VERSION,
} from './constants';
/**
* Default port number.
*/
const DEFAULT_PORT = 8080;
/**
* Default base url endpoint for api.
*/
const DEFAULT_API_PREFIX = '/api';
/**
* Default api version.
*/
const DEFAULT_API_VERSION = '1';
/**
* Default url endpoint for Swagger UI.
*/
const DEFAULT_SWAGGER_PREFIX = '/docs';
/**
* Default bootstrap log level.
*/
const DEFAULT_BOOTSTRAP_LOG_LEVEL = 'warn';
/**
* Setup the Swagger (UI).
*
* @param app
*/
const loggerInstance = new Logger('main');
export const setupSwagger = (app: INestApplication) => {
const options = new DocumentBuilder()
.setTitle(PROJECT_NAME)
.setDescription(PROJECT_DESCRIPTION)
.setVersion(PROJECT_VERSION)
.build();
const document = SwaggerModule.createDocument(app, options);
const path = process.env.SWAGGER_PREFIX || DEFAULT_SWAGGER_PREFIX;
SwaggerModule.setup(path, app, document);
};
/**
* Bootstrap the app.
*/
async function bootstrap() {
const fastifyInstance = fastify({
ignoreTrailingSlash: true,
requestIdHeader: REQUEST_ID_HEADER_KEY,
});
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter(fastifyInstance),
{
logger: [
(process.env.LOG_LEVEL || DEFAULT_BOOTSTRAP_LOG_LEVEL) as LogLevel,
],
abortOnError: false,
},
);
app.enableVersioning({
type: VersioningType.URI,
defaultVersion: process.env.API_VERSION || DEFAULT_API_VERSION,
});
loggerInstance.debug(process.env.NEW_RELIC_LICENSE_KEY);
app.register(fastifyRequestContextPlugin);
app.useLogger(app.get(WinstonLogger));
app.setGlobalPrefix(process.env.PREFIX || DEFAULT_API_PREFIX);
fastifyInstance.addHook('onRequest', fastifyRequestIdHookHandler);
setupSwagger(app);
app.register(cors);
app.register(compression);
app.register(helmet, {
contentSecurityPolicy: {
directives: {
defaultSrc: [`'self'`],
styleSrc: [`'self'`, `'unsafe-inline'`],
imgSrc: [`'self'`, 'data:', 'validator.swagger.io'],
scriptSrc: [`'self'`, `https: 'unsafe-inline'`],
},
},
});
useContainer(app.select(AppModule), { fallbackOnErrors: true });
app.useGlobalPipes(
new ValidationPipe({
transform: true,
whitelist: true,
forbidUnknownValues: true,
transformOptions: {
enableImplicitConversion: true,
},
}),
);
app.useGlobalFilters(new HttpExceptionFilter());
app.useGlobalInterceptors(
new ClassSerializerInterceptor(app.get<Reflector>(Reflector), {
enableImplicitConversion: true,
}),
);
await app.listen(process.env.PORT || DEFAULT_PORT, '0.0.0.0');
}
// Start the app
bootstrap().catch((error) => loggerInstance.error(error));
(node:32394) [FST_MODULE_DEP_FASTIFY-FORMBODY] FastifyWarning.fastify-formbody: fastify-formbody has been deprecated. Use @fastify/[email protected] instead.
(Use `node --trace-warnings ...` to show where the warning was created)