Skip to content

be666/egg-loopback

Repository files navigation

egg-loopback

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-loopback --save

Usage

// {app_root}/config/plugin.js
exports.loopback = {
  enable: true,
  package: 'egg-loopback',
};

Configuration

// {app_root}/config/config.default.js
exports.loopback = {
  app: true,
  client: {
    dir: path.join(appInfo.baseDir, 'app/loopback'),
  }
};

see config/config.default.js for more detail.

Example

loopback-test

// {app_root}/app/controller
module.exports = app => {

  class DemoController extends app.Controller {
    * index() {

      const { Test } = this.app.loopback.models;

      this.ctx.body = yield Test.find();
    }

    * create() {

      const { name } = this.ctx.query;
      const { Test } = this.app.loopback.models;

      yield Test.create({ name });
      this.ctx.body = yield Test.find();
    }

  }

  return DemoController;

};

Questions & Suggestions

Please open an issue here.

License

MIT