How to integrate Payload to NestJS project
I try but not working
/Volumes/Work/project/cms/src/main.ts:36
await payload.initAsync({
^
TypeError: Cannot read properties of undefined (reading 'initAsync')
at bootstrap (/Volumes/Work/project/cms/src/main.ts:36:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as cookieParser from 'cookie-parser';
import * as passport from 'passport';
import payload from 'payload';
import * as session from 'express-session';
import {ExpressAdapter} from '@nestjs/platform-express';
import * as express from 'express';
async function bootstrap() {
const expressApp = express();
const adapter = new ExpressAdapter(expressApp);
const app = await NestFactory.create(AppModule, adapter);
app.use(cookieParser());
// Authentication & Session
app.use(
session({
secret: process.env.AUTH_SESSION_SECRET || 'secret', // to sign session id
resave: false,
saveUninitialized: false,
rolling: true, // keep session alive
cookie: {
maxAge: process.env.AUTH_SESSION_EXPIRES_IN_SECONDS
? parseInt(process.env.AUTH_SESSION_EXPIRES_IN_SECONDS) * 1000
: 3600 * 1000,
httpOnly: true, // so that cookie can't be accessed via client-side script
},
}),
);
app.use(passport.initialize());
app.use(passport.session());
// await payload.initAsync({
// secret: process.env.PAYLOAD_SECRET,
// mongoURL: process.env.MONGODB_URI,
// express: expressApp,
// onInit: async () => {
// payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
// },
// });
await app.listen(3000);
}
bootstrap();
How to integrate Payload to NestJS project
I try but not working
/Volumes/Work/project/cms/src/main.ts:36 await payload.initAsync({ ^ TypeError: Cannot read properties of undefined (reading 'initAsync') at bootstrap (/Volumes/Work/project/cms/src/main.ts:36:17) at processTicksAndRejections (node:internal/process/task_queues:96:5)