The challenge is to build a Bookmarking API that allows one to save, retreive, share, and preview links.
- AWS DynamoDB database for Bookmark data.
- AWS API Gateway implements Bookmark REST API
- AWS Lambda runs business logic invoked by API Gateway and DynamoDB Streams.
- MindTouch LambdaSharp Tool build and deploy clouldformation stack and assets to AWS.
{
"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"
}
For this challenge, we will be using a pre-release version of the LambdaSharp Tool that is easier to configure and use.
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
```
```
dotnet tool install -g LambdaSharp.Tool --version 0.7-RC3
```
git clone git@github.com:LambdaSharp/Bookmarks.git
cd Bookmarks
lash init --quick-start // one time
lash deploy // to propagate code changes
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.
-
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 theApiUrl
that was printed. -
Run the
New Bookmark
request.
curl -X POST \
https://{YOUR_API_GATEWAY_URL}/LATEST/bookmarks \
-H 'Content-Type: application/json' \
-d '{
"Url": "https://www.youtube.com/watch?v=M5NVwuyk2uM"
}'
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.
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
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.
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.
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.