{"id":15362846,"url":"https://github.com/oleg-koval/brevis","last_synced_at":"2026-01-25T00:02:30.691Z","repository":{"id":40727696,"uuid":"241734345","full_name":"oleg-koval/brevis","owner":"oleg-koval","description":"URL shortener service. Build with Serverless AWS Lambda, Atlas Mongo DB, Typescript, Node.js 14","archived":false,"fork":false,"pushed_at":"2024-02-27T03:46:10.000Z","size":330,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T09:42:38.721Z","etag":null,"topics":["aws-lambda","database","hacktoberfest","hacktoberfest2021","nodejs","postman","serverless","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/oleg-koval.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-02-19T21:52:47.000Z","updated_at":"2023-12-15T14:21:50.000Z","dependencies_parsed_at":"2024-10-16T06:01:10.234Z","dependency_job_id":null,"html_url":"https://github.com/oleg-koval/brevis","commit_stats":{"total_commits":91,"total_committers":3,"mean_commits":"30.333333333333332","dds":0.2857142857142857,"last_synced_commit":"efe836929b8bb688c883a7b8d6ba07be2e0562da"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oleg-koval/brevis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-koval%2Fbrevis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-koval%2Fbrevis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-koval%2Fbrevis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-koval%2Fbrevis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleg-koval","download_url":"https://codeload.github.com/oleg-koval/brevis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-koval%2Fbrevis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28739321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["aws-lambda","database","hacktoberfest","hacktoberfest2021","nodejs","postman","serverless","typescript"],"created_at":"2024-10-01T13:04:02.534Z","updated_at":"2026-01-25T00:02:30.677Z","avatar_url":"https://github.com/oleg-koval.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# url-shortener-service\n\n![Continuous Integration](https://github.com/oleg-koval/brevis/workflows/Continuous%20Integration/badge.svg?branch=master)\n![Continuous Delivery](https://github.com/oleg-koval/brevis/workflows/Continuous%20Delivery/badge.svg?branch=master)\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/d52bec96f419528495c4)\n\n## Getting Started\n\nFunctions deployed with Serverless framework to\n[AWS Lambda](https://aws.amazon.com/lambda/) at\n\n[https://7b8kyoyw1e.execute-api.us-east-1.amazonaws.com/prod](https://7b8kyoyw1e.execute-api.us-east-1.amazonaws.com/prod)\n\nData storage - [MongoDB Atlas](https://www.mongodb.com/cloud/atlas). Build with\n[TypeScript](https://www.typescriptlang.org).\n\n[Postman collection](https://www.getpostman.com/collections/d52bec96f419528495c4)\ncan be used to test endpoints locally and remotely.\n\n| function             | type     | path           | execution time | description                                                                                            |\n| -------------------- | -------- | -------------- | -------------- | ------------------------------------------------------------------------------------------------------ |\n| createShortUrlByHash | http     | POST /hash     | -//-           | Request a shortened url. Even if a url was already requested it should generate a new hash.            |\n| getUrlByHash         | http     | GET /url       | -//-           | Get the url by using hash.                                                                             |\n| getStatsByUrl        | http     | GET /stats/url | -//-           | Get the statistics of a url.List of all hashes which were generated and list of ip addresses of users. |\n| cleanup              | schedule | -//-           | `0 0 * * ? *`  | Cronjob which will delete every day at 12.00am hashes of URLs which are not longer used by 12 months.  |\n\n_The hash is made of 8 characters using charset with 64 elements, meaning there\nare 64^8 combinations. It is used as an `_id` in MongoDB schema, so after\n\"cleanup\" job hash becomes available again_\n\n### TODO:\n\nSome things would be great to add:\n\n- use base62 instead of base64 encoding for url hash. Additional characters `$@`\n  are not \"friendly\" for short-url;\n- add black list of urls, during creation check if url is not blacklisted or\n  using bloom filter;\n- use cache with ttl for entries in front of database;\n- alerting in slack channel;\n- based on usage of `GET /stats/url` data can be stored in HDFS or similar to\n  enable stats being aggregated;\n- setup authorization for `GET /stats/url`, make it private;\n\n### Prerequisites\n\nMinimal requirements to set up the project:\n\n- [Node.js](https://nodejs.org/en) v12, installation instructions can be found\n  on the official website, a recommended installation option is to use\n  [Node Version Manager](https://github.com/creationix/nvm#readme). It can be\n  installed in a\n  [few commands](https://nodejs.org/en/download/package-manager/#nvm).\n- A package manager [npm](https://www.npmjs.com). All instructions in the\n  documentation will follow the npm syntax.\n- [Serverless](https://serverless.com/)\n- [docker-compose](https://docs.docker.com/compose)\n- Optionally, a [Git](https://git-scm.com) client.\n\n### Installing\n\nStart by cloning the repository:\n\n```bash\ngit clone git@github.com:oleg-koval/brevis.git\n```\n\nIn case you don't have a git client, you can get the latest version directly by\nusing [this link](https://github.com/oleg-koval/brevis/archive/master.zip) and\nextracting the downloaded archive.\n\nGo the the right directory and install dependencies:\n\n```bash\ncd brevis\nnpm install\n```\n\nInstall serverless:\n\n```bash\nnpm install -g serverless\n```\n\nLogin to serverless:\n\n```bash\nsls login\n```\n\nThat's it! You can now go to the next step.\n\n#### Run locally\n\nEnvironment is managed with [`dotenv`](https://www.npmjs.com/package/dotenv).\nRename `.env.example` to `.env`.\n\nEnvironment variable **MONGODB_CONNECTION_STRING** should be present: f.e.:\n`mongodb://0.0.0.0:27017/test`\n\nRun `mongodb` container in detached mode:\n\n```shell\ndocker-compose up -d\n```\n\nRun tests with coverage:\n\n```shell\nnpm run test:coverage\n```\n\nAlternatively `serverless offline` can be used to run functions locally\n(connection to local MongoDB or hosted should be provided):\n\n```shell\nsls offline start\n```\n\nIt is possible to invoke functions locally (connection to local MongoDB or\nhosted should be provided) with `sls invoke local --function \u003cfunctionName\u003e`\n\nTo shutdown database without delete all containers.\n\n```shell\ndocker-compose stop\n```\n\nTo shutdown database and delete all containers.\n\n```shell\ndocker-compose down\n```\n\n#### Run tests\n\n## Tests\n\nAll tests are being executed using Jest. All tests files live side-to-side with\na source code and have a common suffix: `.spec.ts`. Some helper methods are\nbeing stored in the `test` directory.\n\nThere are three helper scripts to run tests in the most common scenarios:\n\n```bash\nnpm run test\nnpm run test:watch\nnpm run test:coverage\n```\n\n## Continuous Integration / Delivery\n\nGitHub Actions are configured and run the **tests**, **linting**,\n**formatting**, **spellcheck**, **types** whenever a commit is pushed to this\nrepository `master` or any other branch.\n\nAlso used to deploy automatically to AWS Lambda `production` after PR merged to\n`master`.\n\n### Formatting\n\nThis project uses [Prettier](https://prettier.io) to automate formatting.\n\n```bash\nnpm run format\nnpm run format:fix\n```\n\n### Linting\n\nThis project uses [ESLint](https://eslint.org) to enable static analysis.\n\n```bash\nnpm run lint\nnpm run lint:fix\n```\n\n### Automation\n\n- [GitHub Actions](https://github.com/features/actions)\n- [Dependabot](https://dependabot.com/)\n- [Serverless](https://serverless.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-koval%2Fbrevis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleg-koval%2Fbrevis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-koval%2Fbrevis/lists"}