const chalk = require('chalk');
const path = require('path');
const Liana = require('forest-express-sequelize');
const { objectMapping, connections } = require('../models');
module.exports = async function forestadmin(app) {
app.use(await Liana.init({
configDir: path.join(__dirname, '../forest'),
envSecret: process.env.FOREST_ENV_SECRET,
authSecret: process.env.FOREST_AUTH_SECRET,
schemaDir: process.env.FOREST_SCHEMA_DIR,
objectMapping,
connections,
integrations: {
stripe: {
apiKey: process.env.STRIPE_SECRET_KEY,
mapping: 'user.stripeRef',
stripe: require('stripe')
}
}
}));
console.log(chalk.cyan('Your admin panel is available here: https://app.forestadmin.com/projects'));
};
And my model
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const User = sequelize.define('user', {
createdAt: {
type: DataTypes.DATE,
},
updatedAt: {
type: DataTypes.DATE,
},
firstname: {
type: DataTypes.STRING,
},
lastname: {
type: DataTypes.STRING,
},
phonenumber: {
type: DataTypes.STRING,
allowNull: false,
},
authId: {
type: DataTypes.STRING,
},
email: {
type: DataTypes.STRING,
},
stripeRef: {
type: DataTypes.STRING,
},
roles: {
type: DataTypes.ARRAY(DataTypes.STRING),
defaultValue: Sequelize.literal('\'{user}\'::text[]'),
allowNull: false,
},
status: {
type: DataTypes.STRING,
defaultValue: "active",
allowNull: false,
},
nbLateDepartureTotal: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
nbLateDepartureConsecutive: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false,
},
}, {
tableName: 'user',
underscored: true,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
User.associate = (models) => {
User.belongsTo(models.address, {
foreignKey: {
name: 'addressIdKey',
field: 'address_id',
},
as: 'address',
});
User.hasMany(models.booking, {
foreignKey: {
name: 'userIdKey',
field: 'user_id',
},
as: 'bookings',
});
User.hasMany(models.membership, {
foreignKey: {
name: 'userIdKey',
field: 'user_id',
},
as: 'memberships',
});
User.hasMany(models.ticket, {
foreignKey: {
name: 'userIdKey',
field: 'user_id',
},
as: 'tickets',
});
};
return User;
};
@anon15528774 is that ok ?
Is there a log i should find that display that configuration for stripe is ok ?