Show smart actions in forestadmin/agent express

I migrat my project from
forest-express-mongoose": “7.6.0”,

to : "@forestadmin/agent": “^1.8.13”,
@forestadmin/datasource-mongoose”: “^1.4.0”,
“express”: “^4.18.2”,
“mongoose”: “^7.2.0”,

its working but i cannot able to activate my smart actions

the old version
before i init the forest and give him de configDir :

        await forest.init({
            configDir: path.join(__dirname, '../../services/' + serviceName + '/forest'),
            envSecret: CONFIG.credentials.forest.env_secret,
            authSecret: CONFIG.credentials.forest.auth_secret,
            objectMapping: mongoose,
            connections: { default: mongoose.connections[0] },

the actions i declared in tasks file and i export the collection like this

module.exports = () => {
    forest.collection('Area', {
        actions: [createAction],
        fields: [],
        segments: [],

in the new documentation i see we need to creat our collection in collections/*.js file.

i use the agent from global variable agent its ok ??
SERVICE.agent = agent;
or how we callled from another file ??

const { agent } = SERVICE;

module.exports = () => {
    agent.customizeCollection('Area', (Area) => {
        Area.addAction('Mark as Live', {
            scope: 'Global',
            form: [ -------  ],

and i changed my route to :

const { PermissionMiddlewareCreator } = require('forest-express-mongoose');
const controller = require('../../controllers/actions/areasActionsController');
module.exports = (router) => {
    const permissionMiddlewareCreator = new PermissionMiddlewareCreator('Area');

    router.route('/').post(permissionMiddlewareCreator.list(), controller.create);

  • Project name: Mobion_freefloating
  • Environment name: local
  • Agent (forest package) name & version: …
  • Database type: mongoDb mongoose
  • Recent changes made on your end if any: today

Hello @Amine_KHALIFA

You can check out the agent that we internally use for testing for inspiration on the structure.
Don’t hesitate to come back to us if that does not solve your issue.

Note that we don’t enforce anything from our side: you are free to name the folders however you want (or even to put everything in a single file which can be convenient for small agents).

I’ll also link our migration documentation, which you probably already have

1 Like