{"id":19581077,"url":"https://github.com/tsamaya/aws-lambda-url-shortener","last_synced_at":"2026-06-15T15:31:33.446Z","repository":{"id":38567217,"uuid":"282816099","full_name":"tsamaya/aws-lambda-url-shortener","owner":"tsamaya","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-03T21:53:55.000Z","size":1779,"stargazers_count":0,"open_issues_count":12,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T12:17:23.167Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsamaya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-27T06:46:01.000Z","updated_at":"2022-01-15T11:47:31.000Z","dependencies_parsed_at":"2023-02-15T05:01:40.846Z","dependency_job_id":null,"html_url":"https://github.com/tsamaya/aws-lambda-url-shortener","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tsamaya/aws-lambda-url-shortener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsamaya%2Faws-lambda-url-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsamaya%2Faws-lambda-url-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsamaya%2Faws-lambda-url-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsamaya%2Faws-lambda-url-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsamaya","download_url":"https://codeload.github.com/tsamaya/aws-lambda-url-shortener/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsamaya%2Faws-lambda-url-shortener/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34369839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T07:32:30.386Z","updated_at":"2026-06-15T15:31:33.422Z","avatar_url":"https://github.com/tsamaya.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws-lambda-url-shortener\n\n### Design / DB\n\n#### Terms and Concepts\n\n- A [ShortURL](lib/models/ShortURLModel.js) represents a URL that has been shorten. They will be uniquely identified by a shortId.\n\n#### Entity chart\n\n| Entity   | PK                       | SK                       | GSI1PK | GSI1SK |\n| -------- | ------------------------ | ------------------------ | ------ | ------ |\n| ShortURL | SHORTURL#\u0026lt;shortId\u0026gt; | SHORTURL#\u0026lt;shortId\u0026gt; |        |        |\n\n#### Access patterns chart\n\n| Access pattern  | Target     | Parameters | Notes                             |\n| --------------- | ---------- | ---------- | --------------------------------- |\n| ShortURL (CRUD) | Main table | shortId    | Uniqueness requirement on shortId |\n\n### Usage\n\n#### Prerequistes\n\n- dynampdb-local requires `Java Runtime Engine (JRE) version 6.x or newer`\n\n- AWS account configured (default credential in ~/.aws or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set in terminal)\n\n#### Get started\n\n- clone the repo\n\n- cd to/repo/path\n\n- npm install\n\n- npx serverless dynamodb install\n\n- npm run start:offline\n\n#### local dynamodb shell\n\ndynamodb shell:\nhttp://localhost:8000/shell/\n\n#### Test the API locally\n\n```bash\ncurl -X POST \"http://localhost:3001/dev/shorten\" -d '{\"url\":\"https://www.zermatt.ch/en/Webcams\"}' | jq\n\ncurl -X GET \"http://localhost:3001/dev/shorten/cKFT4QP\"  | jq\n\ncurl -X GET \"http://localhost:3001/dev/shorten\"  | jq\n\nopen \"http://localhost:3001/dev/cKFT4QP\"\n```\n\n#### Pagination\n\nThe list operation returns up to 50 shortURLs and then the `LastEvaluatedKey` allows to run a new scan starting this last key.\n\nEncoding the nested object for a querystring:\n\n```js\nconst querystring = require('querystring');\n\nconst LastEvaluatedKey = {\n  SK: {\n    S: 'SHORTURL#cKFT4QP',\n  },\n  PK: {\n    S: 'SHORTURL#cKFT4QP',\n  },\n};\n\nquerystring.escape(JSON.stringify(LastEvaluatedKey));\n\n// outputs\n// '%7B%22SK%22%3A%7B%22S%22%3A%22SHORTURL%23cKFT4QP%22%7D%2C%22PK%22%3A%7B%22S%22%3A%22SHORTURL%23cKFT4QP%22%7D%7D'\n```\n\n### Deploy\n\n```\n➜  aws-lambda-url-shortener git:(master) npx serverless deploy\nServerless: Packaging service...\nServerless: Excluding development dependencies...\nServerless: Creating Stack...\nServerless: Checking Stack create progress...\n........\nServerless: Stack create finished...\nServerless: Uploading CloudFormation file to S3...\nServerless: Uploading artifacts...\nServerless: Uploading service URL-shortener.zip file to S3 (39.3 MB)...\nServerless: Validating template...\nServerless: Updating Stack...\nServerless: Checking Stack update progress...\n......................................................................................................\nServerless: Stack update finished...\nService Information\nservice: URL-shortener\nstage: dev\nregion: eu-west-1\nstack: URL-shortener-dev\nresources: 29\napi keys:\n  None\nendpoints:\n  POST - https://cxxxxxxxxb.execute-api.eu-west-1.amazonaws.com/dev/shorten\n  GET - https://cxxxxxxxxb.execute-api.eu-west-1.amazonaws.com/dev/shorten/{shortId}\n  GET - https://cxxxxxxxxb.execute-api.eu-west-1.amazonaws.com/dev/{shortId}\n  GET - https://cxxxxxxxxb.execute-api.eu-west-1.amazonaws.com/dev/shorten\nfunctions:\n  createShortRL: URL-shortener-dev-createShortRL\n  getShortURL: URL-shortener-dev-getShortURL\n  redirectShortURL: URL-shortener-dev-redirectShortURL\n  listShortURL: URL-shortener-dev-listShortURL\nlayers:\n  None\nServerless: Deprecation warning: Starting with version 3.0.0, following property will be replaced:\n              \"provider.iamRoleStatements\" -\u003e \"provider.iam.role.statements\"\n            More Info: https://www.serverless.com/framework/docs/deprecations/#PROVIDER_IAM_SETTINGS\n\n**************************************************************************************************************************************\nServerless: Announcing Metrics, CI/CD, Secrets and more built into Serverless Framework. Run \"serverless login\" to activate for free..\n**************************************************************************************************************************************\n```\n\n### Contributing\n\nAnyone and everyone is welcome to contribute.\n\n### Issues\n\nFind a bug or want to request a new feature? Please let me know by submitting an issue.\n\n### Licensing\n\nLicensed under the MIT License\n\nA copy of the license is available in the repository's [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsamaya%2Faws-lambda-url-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsamaya%2Faws-lambda-url-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsamaya%2Faws-lambda-url-shortener/lists"}