Development work flow

Hi,

I am trying to run an existing Backend Admin (e.g models , routes etc…), the developer who work earlier commit all files from his system including .env.

I already install all packages and and after npm start i can see below output

Model creation error: ReferenceError: models is not defined
Your application is listening on port 3310.
Your admin panel is available here: https://app.forestadmin.com/projects

Expected behavior

I am expecting the to server run successfully and when I open https://app.forestadmin.com/projects my project it points to my local machine backend.

Actual behavior

In Server startup, I am seeing this error
Model creation error: ReferenceError: models is not defined

as well when I open https://app.forestadmin.com/projects > My Project in browser console below error

chunk.7.3063f605868b6fe645c9.js:325 Error while processing route: project.rendering.index Cannot read property ‘type’ of undefined TypeError: Cannot read property ‘type’ of undefined
at l.h._pushInternalModel (https://app.forestadmin.com/assets/vendor-c07624b566e0c950b81e97ff61b6e54f.js:14785:104)
at https://app.forestadmin.com/assets/vendor-c07624b566e0c950b81e97ff61b6e54f.js:14785:38

Context

Please provide any relevant information about your setup.

  • Package Version:
  • Express Version: ~4.17.1
  • Sequelize Version: ~5.15.1
  • Database Dialect:
  • Database Version:
  • Project Name:

Hello @Tauseef_Ahmed, and welcome to the Forest Admin community :tada: !!!

Can you tell me which version of forest-express-sequelize you are using please?
Do you have an explicit stack trace with the errors, the file and the line where it breaks?

Thank you,

Hi @Guillaume_Cisco,

Thanks for your prompt response, we have “forest-express-sequelize”: “^7.0.0”, installed

On UI side check screenshot below for error details

When I am running the server on Admin Backend there is only this error

Model creation error: ReferenceError: models is not defined

I verified DB access and it works fine also I am login in lumber-cli as well.

I am not sure for existing project if i need to perform some actions from Cli

Regards

Tauseef Ahmed

Ok, so we need to understand why you get the error:

Model creation error: ReferenceError: models is not defined

You will need to find where in your code the models variable is not defined.
Do you know if you need to follow upgrade notes from a previous version of forest-express-sequelize?

Ok i found that and fixing below lines resolve this issue

  Property.associate = (models) => {
  };
  Property.belongsTo(models.c2CUser, {
    foreignKey: {
      name: 'userIdKey',
      field: 'user_id',
    },
    as: 'user',
  });

Seems like the DB structure change after the first setup of Forestadmin I will check with the backend team about that

But even after commenting above lines error is resolve but still, when I access ForestAdmin UI > My App it showing the same error i attached earlier

Do we need to run the lumber update command?

Regards

Tauseef Ahmed

Hi,

Also, can you explain what is

FOREST_ENV_SECRET and FOREST_AUTH_SECRET and from where I get their values?

Regards

Tauseef Ahmed

Hello @Tauseef_Ahmed,

I suggest you to play with lumber update or directly create a new project to see how the structure should look like.

FOREST_ENV_SECRET is the variable pertained to your project in order for us to identify it.
FOREST_AUTH_SECRET is a secret key you can modify, it is used for authentication processus, especially JWT.

I hope it helps :wink:

Hello @Guillaume_Cisco

Right now I have FOREST_AUTH_SECRET which I copied from my colleague env file, can I generate my own FOREST_AUTH_SECRET using my ForestAdmin account? if yes can you explain the steps?

I will try with a new project as well but right now I am documenting steps to init existing project, as we need to hand over this work to another team.

The interesting fact is same code working fine with my colleague who set up this from the beginning but cloning that on my system not, seems like some steps are missing.

Regards

Tauseef Ahmed

Hello @Tauseef_Ahmed,

Do you have the possibility to check what is different with the setup from your colleague?
I think it will help :star_struck:

Be careful when modifying FOREST_AUTH_SECRET, all the users connected to your project will be logged out, as all current JWTs will be invalid. All the users will need to login again to access your data.
FOREST_AUTH_SECRET is not something you generate, you can put any passphrase you want.
It can be a base 64 encoded uuid for example.

I hope it helps :wink:

Hi @Guillaume_Cisco

Thanks yeah I am checking that, we have the exact file structure, anyway i am still verifying

Regards

Tauseef Ahmed