Hello, I’m trying to integrate forestadmin into my nestjs project
Environment: dev
DB: mongodb
Here is my main.ts file :
import { NestFactory } from '@nestjs/core';
import * as compression from 'compression';
import './initEnv';
import { NestExpressApplication } from '@nestjs/platform-express';
import { HttpsOptions } from '@nestjs/common/interfaces/external/https-options.interface';
import { AppModule } from './app.module';
import { createAgent } from '@forestadmin/agent'
import { createMongoDataSource } from '@forestadmin/datasource-mongo';
async function bootstrap() {
let httpsOptions: HttpsOptions
const agent = createAgent({
authSecret: process.env.FOREST_AUTH_SECRET,
envSecret: process.env.FOREST_ENV_SECRET,
isProduction: process.env.ENV === 'prod',
logger: (logLevel, message) => {
console.error(logLevel, message);
},
loggerLevel: 'Error', // Valid values are 'Debug', 'Info', 'Warn' and 'Error'
}).addDataSource(
createMongoDataSource({
uri: 'mongodb://localhost:27017/test',
dataSource: { flattenMode: 'auto' },
})
)
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
cors: {
origin: ['http://localhost:4302', 'http://localhost:4200'],
methods: ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
exposedHeaders: ['Authorization'],
credentials: true,
},
httpsOptions
});
app.use(compression());
await agent.mountOnNestJs(app).start();
await app.listen(3000)
}
bootstrap().catch((err) => process.stderr.write(err + '\n'));
when I run my app it logs:
Info Successfully mounted on NestJS
RangeError: Maximum call stack size exceeded
if I remove the db name here (or if I give it a name that does not exist)
createMongoDataSource({
uri: 'mongodb://localhost:27017(/lqmskdfgjhl)',
dataSource: { flattenMode: 'auto' },
})
it starts ok
Can anyone please help me with this ?