Simple wrapper for the aBird.co API, the world's best, coolest and fastest URL shortening service. Period.
Install aBird.co
npm install abird.co
Require aBird.co
var abird = require('abird.co').fly(options);
The options
object may contain:
apiKey
- Your API key, obtained from your aBird.co profile page. Providing an API key is only required when using theshrink
method.timeout
- API request timeout, in milliseconds. Defaults to3600
.
And you are ready to use this awesome API.
- .shrink(object)
- .expand(mask)
- .delete(mask)
All of these methods return a promise.
let data = {
type: "url",
value: "http://abird.co"
};
abird.shrink(data)
.then(result => {
res.send(result);
})
.catch(error => {
console.error(error);
});
let mask = 'a';
abird.expand(mask)
.then(result => {
res.redirect(302, result.value);
})
.catch(error => {
res.status(404).end();
console.error(error);
});
var mask = 'a';
abird.delete(mask)
.then(() => {
res.status(200).end();
})
.catch(error => {
res.status(400).end();
console.error(error);
});