Node-1st-gen/url-shortener/README.md
This template shows how to shorten URLs automatically as they are added.
See file functions/index.js for the code.
This uses the Bit.ly API.
The dependencies are listed in functions/package.json.
firebase use --add and select your new Firebase project.firebase functions:secrets:set BITLY_ACCESS_TOKEN
firebase deployWe'll be using a simple database structure:
/functions-project-12345
/links
link-123456: "https://my.super.long-link.com/api/user/profile/-jEHitne10395-k3593085"
When a new URL (string) is pushed to /links, it gets replaced with an object containing the original URL and a shortened one.
This way, you can display a clean URL by fetching /links/$linkId/short.
/functions-project-12345
/links
/link-123456
original: "https://my.super.long-link.com/api/user/profile/-jEHitne10395-k3593085",
short: "https://goo.gl/EKDdza"