$ npm i egg-loopback --save
// {app_root}/config/plugin.js
exports.loopback = {
enable: true,
package: 'egg-loopback',
};
// {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.
// {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;
};
Please open an issue here.