A new Tiny URL package with promise/async support.
npm install tiny-shortener








> A new Tiny URL package for Node.js with promise/async and alias support.
Since the TinyURL package is a great option after Google has shut down it's shortener service. But the TinyURL has no Promise support, making it difficult to use with any new ECMA standards. As there is a Pull Request(PR) opened supporting this in the project and still isn't merged, the idea behind __tiny-shortener__ is to make a new package that supports this and goes a step further supporting alias, letting the user personalize the shortened URL.
obs: in case that that the alias isn't available the request still works but falls back to an default shortened link.
bash
npm install tiny-shortener --save
`Using it
$3
* url - Link to be shortened;
* alias - Wanted personalization link;
* Returns > - Shortened link or rejects an error.$3
#### TypeScript
With async/await support but works with Promises as well:
`typescript
import { tiny } from 'tiny-shortener';const asyncRequest = async (): Promise => {
const shortened = await tiny('www.microsoft.com');
const aliased = await tiny('www.typescriptlang.org/', 'tslang');
console.log(
Without alias is: ${shortened}\nWith alias: ${aliased});
};
`#### JavaScript
With Promises support but works with async/await as well:
`javascript
const tiny = require('tiny-shortener').tiny;tiny('www.microsoft.com')
.then(console.log)
.catch(console.error);
// with alias
tiny('www.typescriptlang.org/', 'tslang')
.then(console.log)
.catch(console.error);
});
`#### CLI
`shell
tiny-shortener --url www.example.com
`Or even with alias support:
`shell
tiny-shortener --url www.foo.com --personalization bar
``#### See more
See more in the examples folder.