Skip to content

A Laravel 11 application that shortens long URLs into concise, easy-to-share links.

Notifications You must be signed in to change notification settings

chidozieukaigwe/atarim-url-shortner

Repository files navigation

Atarim URL Shortner Service App

This is a README file for the Atarim url shortner application, a laravel 11 api.

Description

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.

Getting Started

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.

Prerequisites

Installation

  1. Clone the repository: git clone https://github.com/chidozieukaigwe/atarim-url-shortner.git

  2. Install package dependencies: composer install

  3. Launch Laravel Server: php artisan serve access the api at: http://127.0.0.1:8000/api/v1

Api Endpoints

  • POST - /api/v1/encode (expects a payload)
  • GET - /api//v1/decode/{short_code} (returns a payload)

Testing

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

App Notes

  • 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.

About

A Laravel 11 application that shortens long URLs into concise, easy-to-share links.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages