While trying to use the fastify-passport plugin as per documented on the npm documentation i am getting the beloe error while the application is initializing:
server.register(fastifypassport.initialize());
^
TypeError: fastifypassport.initialize is not a function
my index.js looks as below:
'use strict'
import fastify from 'fastify'
import fasifyPassport from 'fastify-passport'
import fastifySecureSession from 'fastify-secure-session'
import loginController from './controller/loginController.js';
import { readFileSync } from 'fs';
import { join } from 'path';
const server = fastify({
logger: true
})
// set up secure sessions for fastify-passport to store data in
server.register(fastifySecureSession, { key: readFileSync(join("", "secret-key")) });
// initialize fastify-passport and connect it to the secure-session storage. Note: both of these plugins are mandatory.
server.register(fasifyPassport.initialize());
server.register(fasifyPassport.secureSession());
server.listen(3000, function (err, address) {
if (err) {
fastify.log.error(err)
process.exit(1)
}
server.log.info(`server listening on ${address}`)
})
Have tried a couple of options like import of the function in {} as well but that also did not work.. Any help would be highly appreciated...