I'm trying to use middleware 'express-fingerprint' in my microservice application ? But i getting an error "Property 'use' does not exist on type 'INestMicroservice'.ts(2339)" ? How do i solve this? Here my code :
async function bootstrap() {
const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule,{
transport : Transport.GRPC,
options : {
url : '0.0.0.0:6000',
package : protobufPackage,
protoPath: 'node_modules/ecommerce-proto/proto/auth.proto'
}
} );
app.use(
Fingerprint({
parameters: [
Fingerprint.useragent,
Fingerprint.acceptHeaders,
Fingerprint.geoip,
],
}),
);
await app.listen();
}
bootstrap();
Thanks all very much
To use middleware in your Nest.js microservice application, you can use NestFactory.create instead of NestFactory.createMicroservice.
Also, use app.useGlobalInterceptors instead of app.use to apply the FingerprintInterceptor to all incoming requests.
At last just ensure you have @nestjs/platform-express installed in order to use NestFactory.create method.