Skip to content

[DRAFT] Decorator API Proposal #1

Description

@dillonredding

Goal

Provide an API for creating a Siren entity from a domain object via the use of annotations.

Example

@Entity()
class Person() {
  @Property()
  givenName: string;

  @Property()
  familyName: string;
}

const p = new Person();
p.givenName = 'Neville';
p.familyName = 'Longbottom';

const json = Siren.stringify(p);
// json => {
//   "class": ["Person"],
//   "properties": {
//     "givenName": "Neville",
//     "familyName": "Longbottom"
//   }
// }

MVP

  • Generate entity from class
  • Use class name as entity's class
  • Include class properties as entity properties
  • Generate a self link

Future

  • Links
  • Actions
  • Alias entity class
  • Alias property names

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions