Feature(s) impacted
The Forest Admin agent initialization and integration with MongoDB using @forestadmin/datasource-mongoose
.
Observed behavior
The Forest Admin agent fails to start and throws the following error:
Failed to initialize Forest Admin: TypeError: factory is not a function
at D:\...\@forestadmin\datasource-customizer\dist\datasource-customizer.js:50:36
at DecoratorsStack.applyQueuedCustomizations (D:\...\@forestadmin\datasource-customizer\dist\decorators\decorators-stack-base.js:31:23)
at DataSourceCustomizer.getDataSource (D:\...\@forestadmin\datasource-customizer\dist\datasource-customizer.js:142:26)
...
This occurs after successfully connecting to MongoDB and registering models. The error seems to originate from how MongooseDatasource
is added to the agent.
Expected behavior
The Forest Admin agent should start successfully after adding the MongooseDatasource
and mounting on Express.js. The admin panel should be accessible at the URL provided during initialization.
Failure Logs
Your application is listening on port 3310.
Connected to MongoDB successfully.
Registered models: [ 'users' ]
Applying users collection customizations
Customizing users collection
Adding Smart Action to users collection
Adding Smart Field to users collection
Adding Smart Segment to users collection
info: Successfully mounted on Express.js
Failed to initialize Forest Admin: TypeError: factory is not a function
at D:\...\@forestadmin\datasource-customizer\dist\datasource-customizer.js:50:36
at DecoratorsStack.applyQueuedCustomizations (D:\...\@forestadmin\datasource-customizer\dist\decorators\decorators-stack-base.js:31:23)
at DataSourceCustomizer.getDataSource (D:\...\@forestadmin\datasource-customizer\dist\datasource-customizer.js:142:26)
...
Context
- Project name:
dibsy-forest
- Team name:
dibsy
- Environment name:
Development
- Agent technology: Node.js
- Agent (forest package) name & version:
@forestadmin/agent
:^1.57.1
@forestadmin/datasource-mongoose
:^1.8.9
- Database type: MongoDB
- Recent changes made on your end if any:
- Migrated from
forest-express-mongoose
to the new@forestadmin/agent
architecture. - Implemented the following initialization logic in
forestadmin.js
:const agent = createAgent({ authSecret: process.env.FOREST_AUTH_SECRET, envSecret: process.env.FOREST_ENV_SECRET, isProduction: process.env.NODE_ENV === 'production', }); agent.addDataSource(new MongooseDatasource(mongoose)); await agent.mountOnExpress(app).start();
- Added customizations using
customizeCollection()
for theusers
collection.
- Migrated from