JSPM

loopback-component-meta

1.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 28
  • Score
    100M100P100Q46838F
  • License MIT

LoopBack component for retrieving meta data about the API Models

Package Exports

  • loopback-component-meta

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (loopback-component-meta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

loopback-component-meta

Greenkeeper badge

CircleCI Dependencies Coverage Status

Component for LoopBack that adds a Meta model that can be used to retrieve meta data about the model definitions.

Installation

Install the module

$ npm install --save loopback-component-meta

Configure the module in server/component-config.json

{
  "loopback-component-meta": {
    "enableRest": true,
    "filter": [
      "ACL",
      "AccessToken",
      "RoleMapping",
      "Role",
      "User"
    ],
    "acls": [{
      "accessType": "*",
      "principalType": "ROLE",
      "principalId": "$unauthenticated",
      "permission": "ALLOW"
    }]
  }
}

Usage

After installation you should be able to retrieve data about your models through the Meta endpoint on your API:

Retrieve all models:

http://0.0.0.0:3000/api/Meta

[{
    id: "Category",
    name: "Category",
    properties: {
        name: {
            type: "String",
            required: true
        }
    },
    acls: [],
    base: "BaseModel",
    idInjection: true,
    methods: {},
    mixins: {
        ModifiedTimestamp: {}
    },
    relations: {
        products: {
            type: "hasMany",
            model: "Product",
            foreignKey: ""
        }
    },
    strict: false,
    validations: []
}, {
    id: "Product",
    name: "Product",
    properties: {
        name: {
            type: "String",
            required: true
        }
    },
    acls: [],
    base: "BaseModel",
    idInjection: true,
    methods: {},
    mixins: {
        ModifiedTimestamp: {}
    },
    relations: {
        category: {
            type: "belongsTo",
            model: "Category",
            foreignKey: ""
        }
    },
    strict: false,
    validations: []
}]

Retrieve one model:

http://0.0.0.0:3000/api/Meta/Category

{
    id: "Category",
    name: "Category",
    properties: {
        name: {
            type: "String",
            required: true
        }
    },
    acls: [],
    base: "BaseModel",
    idInjection: true,
    methods: {},
    mixins: {
        ModifiedTimestamp: {}
    },
    relations: {
        products: {
            type: "hasMany",
            model: "Product",
            foreignKey: ""
        }
    },
    strict: false,
    validations: []
}