The module can combine many Bitly accounts together to be an extensible quota usage.
npm install @waynechang65/unlimited-bitly



npm install --save @waynechang65/unlimited-bitly
`
* 在您的專案環境中,引用 @waynechang65/unlimited-bitly模組。
Include @waynechang65/unlimited-bitly package in your project
`javascript
const unlimited_bitly = require('@waynechang65/unlimited-bitly');
`
* 接下來,用async函式包含下面幾行程式就搞定了。值得注意的是,BITLY_KEYS陣列要放Bitly帳號的KEY,放幾個帳號都可以。(以下範例是4個帳號)
Add programs below in an async function in your project. It should be mention that please put keys of Bitly accounts in BITLY_KEYS array.(example shows below by 4 Bitly accounts)
`javascript
const BITLY_KEYS = [
process.env.TOSMM_BITLY_1_KEY,
process.env.TOSMM_BITLY_2_KEY,
process.env.TOSMM_BITLY_3_KEY,
process.env.TOSMM_BITLY_4_KEY
];
let ubitly = unlimited_bitly.init(BITLY_KEYS);
try {
console.log(await ubitly.shorten(LONG_URL));
} catch(e) {
console.log(e);
}
`
* shorten函式會傳回已縮完的短網址。
The function "shorten" will return a shortened url.
如何跑範例程式? (How to run the example ?)
* 從GitHub下載unlimited-bitly專案程式
Clone unlimited-bitly from GitHub
`
git clone https://github.com/WayneChang65/unlimited-bitly.git
`
* 在unlimited-bitly專案環境中,下載必要模組。
Install dependencies in the cloned unlimited-bitly folder
`
npm install
`
* 將Bitly Key增加TOSMM_BITLY_1_KEY-TOSMM_BITLY_4_KEY的環境變數中。
Add Bitly Key to env variables(TOSMM_BITLY_1_KEY~TOSMM_BITLY_4_KEY).
* 透過 npm 直接使用以下指令。(實際範例程式在 ./examples/demo.js)
Run it with npm. (the demo example is in ./examples/demo.js)
`
npm start
``