Giter VIP home page Giter VIP logo

gpt-url-redirect's Introduction

URL Shortener

This URL Shortener application is built with the AWS Cloud Development Kit (CDK) in TypeScript. It provides a simple RESTful API to create and manage short URLs that redirect to original URLs. The prompts which were used to generate this.

Screenshot

Architecture

The application consists of two AWS Lambda functions and an Amazon DynamoDB table, exposed via an Amazon API Gateway REST API.

  • Create Short URL Lambda: Processes incoming requests to create a short URL for a given original URL.
  • Redirect Short URL Lambda: Processes incoming requests to redirect from a short URL to its corresponding original URL.
  • Amazon DynamoDB: Stores the mapping between short URLs and original URLs.

Backend

flowchart TD
    A[API Gateway] -->|POST /create| B1[Lambda: CreateShortUrlHandler]
    A -->|GET /:shortUrl| B2[Lambda: RedirectToLongUrlHandler]
    B1 --> C[DynamoDB: UrlMappingsTable]
    B2 --> C

    subgraph Serverless Backend Stack
        A
        B1
        B2
        C
    end

Getting Started

Prerequisites

Deployment

  1. Clone the repository:
git clone https://github.com/your-username/url-shortener.git
cd url-shortener
  1. Install dependencies:
npm install
  1. Bootstrap the CDK app:
cdk bootstrap
  1. Deploy the URL Shortener application:
cdk deploy

The cdk deploy command will create and deploy the necessary AWS resources, including the Lambda functions, API Gateway, and DynamoDB table.

Usage

You can use any REST client (e.g., Postman, curl) to interact with the deployed API.

  • To create a short URL, send a POST request to the /create endpoint with a JSON payload containing the originalUrl. The API will return the short URL:
curl -X POST https://your-api-id.execute-api.your-region.amazonaws.com/prod/create \
  -H "Content-Type: application/json" \
  -d '{"originalUrl": "https://www.example.com"}'

To use the short URL, send a GET request to the short URL path:

curl -X GET -L https://your-api-id.execute-api.your-region.amazonaws.com/prod/{shortUrl}

The API will redirect you to the corresponding original URL. Note the -L flag is used to follow the redirect.

Clean Up

To remove the deployed resources, run the following command:

cdk destroy

gpt-url-redirect's People

Contributors

skorfmann avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.