Yoctol / bottender

⚡️ A framework for building conversational user interfaces.
https://bottender.js.org
MIT License
4.22k stars 335 forks source link

feat: support line multiple channel using getConfig #770

Closed chentsulin closed 4 years ago

chentsulin commented 4 years ago

To solve #642, we need a new option - an async getConfig function to get (accessToken, channelSecret) from somewhere:

module.exports = {
  channels: {
    line: {
      enabled: true,
      path: '/webhooks/line/:channelId',
      async getConfig({ params }) {
        console.log(params.channelId);
        // ...get the config from the API, database or wherever you like when every time receiving a new event 
        return {
          accessToken,
          channelSecret,
        };
      },
    },
  },
};
codecov-io commented 4 years ago

Codecov Report

Merging #770 into release/1.5 will increase coverage by 0.12%. The diff coverage is 88.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release/1.5     #770      +/-   ##
===============================================
+ Coverage        80.93%   81.06%   +0.12%     
===============================================
  Files              108      108              
  Lines             4706     4738      +32     
  Branches          1141     1149       +8     
===============================================
+ Hits              3809     3841      +32     
  Misses             869      869              
  Partials            28       28              
Impacted Files Coverage Δ
packages/bottender/src/slack/SlackConnector.ts 92.12% <ø> (ø)
...ckages/bottender/src/telegram/TelegramConnector.ts 96.55% <ø> (ø)
packages/bottender/src/types.ts 100.00% <ø> (ø)
packages/bottender/src/viber/ViberConnector.ts 85.96% <ø> (ø)
packages/bottender/src/server/Server.ts 10.46% <16.66%> (+0.70%) :arrow_up:
...ckages/bottender/src/whatsapp/WhatsappConnector.ts 88.23% <33.33%> (-2.39%) :arrow_down:
packages/bottender/src/line/LineConnector.ts 95.90% <95.34%> (+4.31%) :arrow_up:
packages/bottender-express/src/registerRoutes.ts 84.21% <100.00%> (ø)
packages/bottender/src/console/ConsoleBot.ts 100.00% <100.00%> (ø)
packages/bottender/src/line/LineBot.ts 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 99cf577...255657a. Read the comment docs.