Skip to content

blizzardzheng/egg-aliyun-fc

Repository files navigation

egg-aliyun-fc

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

Install

$ npm i egg-aliyun-fc --save

Usage

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

Configuration

// {app_root}/config/config.default.js
exports.aliyunFc = {
  client: {
    accountId: '<>',
    accessKeyID: '<>',
    accessKeySecret: '<>',
    region: '<>'
  }
};

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

Example

export default class  queryService extends Service {
  async test() {
   const fc = this.ctx.fc;
   const functioncode = await fc.getFunctionCode('anymock', 'handler')// 这里的详细api请参见 http://doxmate.cool/aliyun/fc-nodejs-sdk/api.html#client__createFunction
   const functioncode1 = await fc.createFunction('iat_anymock', {
        functionName: 'xxx',
        handler: 'main.handler',
        runtime: 'nodejs8',
        memorySize: 100,
        timeout: 5,
        code: `
          function(event, context, callback) { 
            console.log('hello world');
            callback(null, 'hello world'); 
          }
        `
      }); // 增加了string形式的create 和update
  }
}

Questions & Suggestions

Please open an issue here.

License

MIT

About

阿里云 fc 的egg插件

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published