https://github.com/shirokovnv/url_shortener
URL Shortener app written in elixir.
https://github.com/shirokovnv/url_shortener
elixir phoenix-framework url-shortener
Last synced: 9 months ago
JSON representation
URL Shortener app written in elixir.
- Host: GitHub
- URL: https://github.com/shirokovnv/url_shortener
- Owner: shirokovnv
- License: mit
- Created: 2022-08-20T17:58:59.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-14T14:00:59.000Z (over 3 years ago)
- Last Synced: 2025-10-10T11:35:23.530Z (9 months ago)
- Topics: elixir, phoenix-framework, url-shortener
- Language: Elixir
- Homepage:
- Size: 59.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# UrlShortener
![ci.yml][link-ci]
**Oh, no! Another URL shortener app.**
## Dependencies
* [Docker][link-docker]
* [Make][link-make]
* [Phoenix framework][link-phx]
* [PostgreSQL][link-pgsql]
## Project setup
**From the project root, inside shell, run:**
- `make pull` to pull latest images
- `make init` to install fresh dependencies
- `make up` to run app containers
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
* `make down` - to extinguish running containers
* `make help` - for additional commands
## Howitworks
**There are two API methods:**
_Shorten a long URL_ by getting an incremental counter and converting it to base62 format.
```
curl --location --request POST 'http://localhost:4000/' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"long_url": "https://example.com"
}'
```
**It responds with:**
```
{
"short_url": "http://localhost:4000/2bU"
}
```
_Reading short URL_ and redirecting to the matched long URL.
**Just follow the link builded from the previous step:**
```
curl --location --request GET 'http://localhost:4000/2bU'
```
**You will be redirected to the previously stored long URL**.
## Benchmarks
Run `make bench` for benchmarking tests.
### Thats literally it. Good job :)
## License
MIT. Please see the [license file](LICENSE.md) for more information.
[link-ci]: https://github.com/shirokovnv/url_shortener/actions/workflows/ci.yml/badge.svg
[link-phx]: https://www.phoenixframework.org/
[link-pgsql]: https://www.postgresql.org/
[link-docker]: https://www.docker.com/
[link-make]: https://www.gnu.org/software/make/manual/make.html