API Extension

Installing an API Extension

  • Download and extract the Colmena Starter into the extensions folder of your Colmena installation.

  • Run lerna ls in the Colmena project root and verify that it lists the entry @colmena/module-api-starter

  • Open the file apps/api/package.json and add this line to the dependencies array:

"@colmena/module-api-starter": "0.0.0",
  • Run lerna bootstrap from the project root to link the new package to the API.

Configure the LoopBack API

  • Open the file config/default.yaml and add this line to the colmena.modules object. This makes sure the API loads the new module.
colmena:
  modules:
    ...
    '@colmena/module-api-starter': true
    ...
  • Start the API by running npm run dev:api from the project root.

  • If the module is installed successfully you should see this message:

[loopback-modules] Registering models from module: @colmena/module-api-starter

Load the sample data

The starter kit comes with sample data. To load this data run:

npm run initdb

Please note that this will wipe any data from the development database!

Generate the LoopBack SDK

Now that the endpoint is working we need to update the LoopBack SDK. This makes sure that the Admin Extension can easily consume the new endpoints.

In order to re-generate the LoopBack SDK run the following command from the project root:

npm run sdk

This will output a list of newly generated files. These files should be committed to the project as they describe the structure of the API.