Skip to content

LambdaSharp/Bookmarks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LambdaSharp Bookmarker

About this challenge

The challenge is to build a Bookmarking API that allows one to save, retreive, share, and preview links.

Infrastructure:

Bookmark Schema

{
    "ID": "32a7cf5a-35be-459a-b586-ec2bed2f4fef",
    "Url": "https://www.youtube.com/watch?v=M5NVwuyk2uM",
    "Title": "The Dream Smartphone! (2019)",
    "Description": "The impossible dream of the perfect smartphone in ...",
    "ImageUrl": "https://i.ytimg.com/vi/M5NVwuyk2uM/maxresdefault.jpg"
}

Setup - .NET Core and AWS

Setup - LambdaSharp Tool (aka lash)

For this challenge, we will be using a pre-release version of the LambdaSharp Tool that is easier to configure and use.

Upgrade lash

If you already have the LambdaSharp Tool installed, unfortunately you cannot simply upgrade it to a pre-release version. First, you have to uninstall the previous version, then install the new version.

```
dotnet tool uninstall -g LambdaSharp.Tool
dotnet tool install -g LambdaSharp.Tool --version 0.7-RC3
```

Install lash

```
dotnet tool install -g LambdaSharp.Tool --version 0.7-RC3
```

Clone Bookmarker repository

git clone git@github.com:LambdaSharp/Bookmarks.git

Build and Deploy

cd Bookmarks
lash init --quick-start     // one time
lash deploy                 // to propagate code changes

Level 0 -- Add URL to DynamoDB

Invoke the POST endpoint of the API Gateway that was created when you ran lash deploy to add a URL to DynamoDB. You can do this through the Postman collection that is provided or through a Curl command in your terminal. You will need to grab the ApiUrl: API Gateway URL that is printed at the end of the lash deploy command.

Postman

  • Import the collection into Postman by clicking the Import button on the top left of the application.

  • Add a Global variable bookmark_api, and set the value to the ApiUrl that was printed.

  • Run the New Bookmark request.

Curl

curl -X POST \
  https://{YOUR_API_GATEWAY_URL}/LATEST/bookmarks \
  -H 'Content-Type: application/json' \
  -d '{
    "Url": "https://www.youtube.com/watch?v=M5NVwuyk2uM"
}'

Level 1 -- Support Short URLs

Currently, bookmarks are created with a 37-character id (a guid) like 10cffe9e-ace5-444c-836b-635e6ec207d3. Modify the POST AddBookmark API endpoint to instead use a short ID that is still unique. This will allow a future version of our Bookmark service to generate short urls like https://bookmark.er/xYq.

Ideally, you would NOT use a simple sequential integer as that would allow our competitors to know how many bookmarks are in our system.

Level 2 -- Save OpenGraph Data

When a new bookmark is added to DynamoDB, it will only store the ID and Url. However, we want to record more information about our Bookmark in order to support a preview feature (Level 3). On an insert into our DynamoDB table, the lambda function DynamoFunction will be triggered.

Modify that function to retrieve the OpenGraph data from the URL and update the Bookmark in DynamoDB to include the following fields: Title, Description, and ImageUrl.

Retrieving OpenGraph Data from a URL

Level 3 -- Generate HTML Preview

Modify the API Gateway lambda function GetBookmarkPreview to return an HTML preview of a Bookmark. The HTML should include OpenGraph MetaData tags so that the preview renders correctly when the preview URL is shared in apps such as Slack, iMessage, etc.

Writing out OpenGraph Example

sharing screenshot

Level 4 -- Add Redirector

Modfy Module.yml file to add a new API endpoint called GET:/redirect/{id} which invokes a method that performs an HTTP redirect to the original Bookmark url.

Boss Level -- Add Categories

Extend the Bookmark data model to include a list of categories that are relevant to the Bookmark. Your job is to figure out how to get the list of categories.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages