Giter Site home page Giter Site logo

pyaesone17 / urener Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 270 KB

Url shortener powered by Laravel service container, automatic dependency injection, pluggable Identity generator protected with passport oauth server

PHP 95.75% Vue 0.45% HTML 3.80%

urener's Introduction

About Urener

URENER is a url shortener web application based on laravel. It mainly use automatic dependency injection of Laravel service container to abstract the implementation from high level code. Thanks to Taylor Otwell for this awesome framework. This repository focus on the pricinple of "Code to interface" and SOLID. The features of the application include

  • Custom slug on top of the Id generator
  • Logging the visitor
  • Laravel Passport Authentication
  • Caching the url
  • Unit Test & Integration Test & Behavior Test
  • DNS checker validation
  • Pluggable slug generator
  • CLI powered administration

Urener is accessible, yet powerful and robust application to make shorten url.

Installation

Install dependecy of the application

composer install

Migrate the database for laravel passport and application tables

php artisan migrate

Install laravel passport

php artisan passport:install

Serve the application

php artisan serve

Application Flow

1. Generate the client for password grant

php artisan passport:client --password

2. Create Admin User

php artisan make:admin

3. Issue Access Token

    $response = $http->post('http://your-app.com/oauth/token', [
        'form_params' => [
            'grant_type' => 'password',
            'client_id' => 'client-id',
            'client_secret' => 'client-secret',
            'username' => '[email protected]',
            'password' => 'my-password',
            'scope' => '',
        ],
    ]);

4. Create url shortener

POST /admin/urls

{
    "alias" : "hcm",
    "redirect_url" : "https://hinchatmal.com/",
}

5. Visit the alias url, boom you are redirected to the destination

http://127.0.0.1:8000/hcm

Quick Start

Here is a quick start to easily generate and test the app

1. Seed the data via artisan

php artisan db:seed

2. List all of the urls via artisan

php artisan urlshortener:list 1

Available Endpoints

1. View url shortener list

GET /admin/urls

2. View url shortener detail

GET /admin/urls/1

3. Create url shortener

POST /admin/urls

{
    "alias" : "hcm",
    "redirect_url" : "https://hinchatmal.com/",
}

4.Update url shortener

PUT /admin/urls/1

{
    "alias" : "hcm",
    "redirect_url" : "https://hinchatmal.com/",
}

5. Delete url shortener

DELETE /admin/urls/1

Command Line

Make the admin user via cli for api authentication

php artisan make:admin

Add the urlshortener via cli easily

php artisan urlshortener:make

List the available urlshorteners via cli

php artisan urlshortener:list {page(1,2,3,4)}

Configuration

ID Generator Driver

Currently the app supports two style for generating random slug "youtube" style short id generator and "uuid" generator, configure it on .env.

ID_GENERATOR="youtube"

DNS rule validation

By default the application will validate whether provided redirect url is existed on realword or not. To disable that feature, simply set false on .env. (Please not that DNS checking is disabled by default in Testing environment)

DNS_CHECK=false

Testing

/vendor/bin/phpunit

urener's People

Contributors

pyaesone17 avatar nyanwin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.