rafaeelaudibert / urlShortener

πŸ“ Custom URL Shortener, using MongoDB and AWS Lambda.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URL Shortener πŸ“

Custom URL Shortener, using MongoDB and AWS Lambda.

Usage πŸ–₯️

  • Create a free MongoDB database (you can use Mongo Atlas M0).
  • Fill the environment variables on .env.sample and copy it to .env file.
  • Deploy the functions to AWS Lambda (or any other lambda provider, if you prefer)
  • Configure your domain manager to point to it

Configuring domain on AWS

Using Route 53 and API Gateway:

  • In Lambdas, select the app you just created (probably with the name url-shortener-prd)
  • In the Resources tab, click on the link to access ApiGatewayRestApi
  • In API Gateway, select "Custom domain names"
  • Create a new domain name in the format you want, for example, url.yourdomain.com. It will create a new domain in the format <id>.execute-api.<your-region>.amazonaws.com
  • On Route53, create a new A type record, pointing to the domain created above

Endpoints ⚑

Shorten

Send a POST request to /shorten, with the shortUrl and longUrl parameters on body, and a x-secret headers, which should match the one filled on .env file, if you filled it.

Redirect

Send a GET request to /request/:shortUrl passing the shortUrl, to be redirected to the longUrl.

What is missing?

[ ] Find a way to solve the manual step to configure the domain, using, probably, serverless-domain-manager.

Author πŸ§™β€β™‚οΈ

About

πŸ“ Custom URL Shortener, using MongoDB and AWS Lambda.


Languages

Language:JavaScript 100.0%