This is a README file for the Atarim url shortner application, a laravel 11 api.
The application is an api that has two api endpoints: 'decode' and 'encode' that enables urls to be encoded and decoded. Below explains how the two endpoints work:
- encode: receives a url, encodes the url with a shortcode and produces a shortened url based on the api domain.
- decode: receives a url shortcode, decodes the shortcode and the returns the original url that was associated with that shortcode.
The application uses an SQL Lite database, update your .env
file and add the following variable: DB_CONNECTION=sqlite
. You can also comment out the following .env variables to ensure no database complications occur with the project:
- DB_HOST=127.0.0.1
- DB_PORT=3306
- DB_DATABASE=laravel
- DB_USERNAME=root
- DB_PASSWORD= ,
Connect to the database via a GUI, and access the file: /database/database.sqlite
to access the application database.
- Http Client - [Postman: https://www.postman.com/] or [Insomnia: https://insomnia.rest/] to create
POST|GET
requests to the api. - Database GUI [TablePlus: https://tableplus.com/] allows you to visually interact with the database.
- PHP 8.0^
- Laravel 11
- SQL Lite
-
Clone the repository:
git clone https://github.com/chidozieukaigwe/atarim-url-shortner.git
-
Install package dependencies:
composer install
-
Launch Laravel Server:
php artisan serve
access the api at: http://127.0.0.1:8000/api/v1
- POST -
/api/v1/encode
(expects a payload) - GET -
/api//v1/decode/{short_code}
(returns a payload)
The test suite uses PHPUnit: Use the following commands to run the tests suites associated with this application:
- Run Unit Tests:
php artisan test --filter=unit
- Run Feature Tests:
php artisan test --filter=feature
- Run Full Test Suite:
php artisan test
- This package is used as the decode and encode algorithm: https://github.com/vinkla/laravel-hashids
- URLs are persisted via an SQL Lite database
- Api endpoints return JSON
- Global error handler catching 404 not found exceptions on the api. Review
/bootstrap/app.php
file to see the handler.