@kezios/forest-express-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.1.4-alphaΒ β€’Β PublicΒ β€’Β Published

Forest Express Decorator

MIT License

πŸš€ Decorators for Express Forest Admin

Installation

yarn add forest-express-decorator

Usage (🚧 WIP!)

Collection :

@Collection('customers')
class CustomerCollection extends BaseCollection {
  @SmartField({
    type: 'String',
    get: (customer) => `${customer.firstname} ${customer.lastname}`,
    set: (customer, fullname) => {
      fullname.split(' ');
      customer.firstname = names[0];
      customer.lastname = names[1];

      return customer;
    },
  })
  fullname;

  @SmartAction(GenerateInvoice)
  generateInvoice: GenerateInvoice;
}

Smart action :

class GenerateInvoice extends BaseSmartAction {
    @SmartActionField({
        type: 'Number',
        label: 'Price',
        description: 'The price to generate invoice in $'
        isRequired: true,
    })
    price;

    onCall = (req, res) => {
        const price = req.body.data.attributes.values.price;
        // .....
        return res.status(200).send({success: 'Invoice generated !'})
    }
}

Related

Forest Admin Express

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @kezios/forest-express-decorator

Weekly Downloads

69

Version

0.1.4-alpha

License

MIT

Unpacked Size

32.7 kB

Total Files

41

Last publish

Collaborators

  • maximesenger
  • alexandre-f
  • justin-martin-dev