kurierjs / kurier

TypeScript framework to create JSON:API compliant APIs
https://kurier.readthedocs.io/en/latest/
MIT License
61 stars 9 forks source link

Support JSON-based, light-weight syntax for resource definition #289

Closed joelalejandro closed 2 years ago

joelalejandro commented 3 years ago

It'd be interesting to make types in Application a dual-type property:

types: typeof Resource[] | ResourceSchemaList;

So in the Application constructor, we could dynamically create Resource classes accordingly.

ResourceSchemaList would be an object-based list like:

{
  ResourceName: {
    attributes: {},
    relationships: {}
  }
}

The resourceSchemaListToResourceClasses method would look something like:

Object.entries(resourceSchemaList).map(([resourceName, schemaDefinition]) => class extends Resource {
  static schema = { ...schemaDefinition };
});
joelalejandro commented 3 years ago

Could be a way to mitigate a problem described in #294.

joelalejandro commented 2 years ago

Supporting this feature implies a major rewrite of the way Processors work, it's too much of a cost for a minimal benefit. I'm calling off development on this.