Hello!
I thought it was the good time to close my previous issue as I think that now, I have a reproducible bug
As I was trying to update my project from version 5.xxx to 7/8, I was like (at the end), let’s create a fresh new project.
I so created a new project (mostly to test the upgrade/translate) with the latest version of forest-cli
. Well, if you create a project, then following (in the right order, from top to bottom) the following doc:
You will see that you get this amazing… empty… screen Uh oh, no collections found.
Note: It might have some breaking changes between the version 8 and your doc, I am aware of it. I just want to get to the latest version so I don’t have to struggle for a while…
Expected behavior
When I follow the two following documentation, I should be able to access my database. When I create the project, I have access to it.
Actual behavior
Once I translate config/databases.ts
, middlewares/forestadmin.ts
, models/index.ts
and the models under models/
, I have this screen…
I tried for a while to see if there is any “hidden logs” or “silent errors” but nothing…
Failure Logs
I have no logs
Context
Let me share you my files
config/database.ts
import { ConnectionOptions } from "mongoose";
import { DatabaseConfiguration } from "forest-express-mongoose";
import { resolve } from 'path';
const databaseOptions: ConnectionOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
const databasesConfiguration: DatabaseConfiguration[] = [{
name: 'default',
modelsDir: resolve(__dirname, '../models'),
connection: {
url: process.env.DATABASE_URL,
options: { ...databaseOptions },
},
}];
export default databasesConfiguration;
middlewares/forestadmin.ts
import * as chalk from 'chalk';
import { join } from 'path';
import { init, LianaOptions } from "forest-express-mongoose";
import { objectMapping, connections } from '../models';
import { Application } from "express";
export = async function forestadmin(app: Application): Promise<void> {
const lianaOptions: LianaOptions = {
configDir: join(__dirname, '../forest'),
envSecret: process.env.FOREST_ENV_SECRET,
authSecret: process.env.FOREST_AUTH_SECRET,
objectMapping,
connections,
}
app.use(await init(lianaOptions));
console.log(chalk.cyan('Your admin panel is available here: https://app.forestadmin.com/projects'));
return;
};
models/notes.ts
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
import {Schema} from 'mongoose';
export interface INote {
created_at: number,
name: string,
content: string,
}
// This section contains the properties of your model, mapped to your collection's properties.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const schema = new Schema<INote>({
'created_at': {type: Number, required: true},
'name': {type: String, required: true},
'content': {type: String, required: true},
}, {
timestamps: false,
});
export default schema;
models/index.ts
import * as Mongoose from 'mongoose';
import {model} from 'mongoose';
import databasesConfiguration from '../config/databases';
import noteSchema, {INote} from './note';
const connections: Record<string, Mongoose.Connection> = {};
const objectMapping = Mongoose;
const connection = Mongoose.createConnection(databasesConfiguration[0].connection.url, databasesConfiguration[0].connection.options);
connections[connection.name] = connection;
let Notes = model<INote>('Notes', noteSchema, 'Notes');
export {
objectMapping,
connections,
Notes,
};
package.json
{
"name": "emixam23-update1",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./dist/server.js",
"build": "rm -rf ./dist && npm run compile && npm run cp-config",
"dev": "tsc-watch --onSuccess \"node ./dist/server.js\"",
"compile": "tsc",
"lint": "eslint . -c .eslintrc.json --ext .ts",
"cp-config": "cp .env ./dist/"
},
"dependencies": {
"body-parser": "1.19.0",
"chalk": "~1.1.3",
"cookie-parser": "1.4.4",
"cors": "2.8.5",
"debug": "~4.0.1",
"dotenv": "~6.1.0",
"express": "~4.17.1",
"express-jwt": "6.0.0",
"forest-express-mongoose": "^8.0.0",
"mongoose": "~5.8.2",
"morgan": "1.9.1",
"require-all": "^3.0.0"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/mongoose": "^5.11.97",
"@types/node": "^16.4.3",
"tsc-watch": "^4.4.0",
"typescript": "^4.3.5"
}
}
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"pretty": true,
"sourceMap": false,
"target": "es2017",
"outDir": "./dist",
"baseUrl": "./",
"types" : ["node", "express", "forest-express-mongoose"],
"allowJs": true
},
"include": ["./**/*", ".env"],
"exclude": ["node_modules", "dist"]
}
I hope I will be able to make it work soon, really need it to move forward in our project
Thanks again for your work
Max