Git Product home page Git Product logo

kanye-api's Introduction

Kanye API

This project is created using https://github.com/philbates35/laravel-starter.

System requirements

You should ensure that you have the following installed on your host machine:

  • Git
  • Docker
  • Docker-compose
  • pnpm v8

That's it!

Why isn't Node a system requirement?

We use pnpm's use-node-version in .npmrc to manage the node version to use in the project, which means that you don't need a locally installed Node. This way we can ensure that all developers are using the same version of Node.

Getting started

  1. Clone this repo:

    git clone [email protected]:philbates35/kanye-api.git
    cd kanye-api
  2. Create the .env file:

    cp .env.example .env
  3. Install composer dependencies, then start Octane (FrankenPHP):

    docker-compose up -d
  4. Wait around 30 seconds, then set application key, create the database and run migrations:

    docker-compose exec php composer run post-create-project-cmd
  5. Run the database seeder to create a user that has an API token (test-user-api-token) that you can authenticate with:

    docker-compose exec php php artisan db:seed
  6. You can now test the application, using Postman, curl, or your HTTP client of choice you can view 5 random Kanye quotes by authenticating with the test-user-api-token API token:

    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" https://localhost/api/quotes
    ["I'm going to personally see to it that Taylor Swift gets her masters back. Scooter is a close family friend","Who made up the term major label in the first place???","I'm the best","We as a people will heal. We will insure the well being of each other","You basically can say anything to someone on an email or text as long as you put LOL at the end."]
    # Repeated requests give the same set of quotes
    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" https://localhost/api/quotes
    ["I'm going to personally see to it that Taylor Swift gets her masters back. Scooter is a close family friend","Who made up the term major label in the first place???","I'm the best","We as a people will heal. We will insure the well being of each other","You basically can say anything to someone on an email or text as long as you put LOL at the end."]
    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" https://localhost/api/quotes
    ["I'm going to personally see to it that Taylor Swift gets her masters back. Scooter is a close family friend","Who made up the term major label in the first place???","I'm the best","We as a people will heal. We will insure the well being of each other","You basically can say anything to someone on an email or text as long as you put LOL at the end."]
    
    # Make the following POST request to refresh the quotes
    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" -X POST https://localhost/api/refresh
    
    # Now the quotes are different
    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" https://localhost/api/quotes
    ["The world is our family","I feel like I'm too busy writing history to read it.","I'm nice at ping pong","The media tries to kill our heroes one at a time","All you have to be is yourself"]
    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" https://localhost/api/quotes
    ["The world is our family","I feel like I'm too busy writing history to read it.","I'm nice at ping pong","The media tries to kill our heroes one at a time","All you have to be is yourself"]
    curl -k -H "Accept: application/json" -H "Authorization: Bearer test-user-api-token" https://localhost/api/quotes
    ["The world is our family","I feel like I'm too busy writing history to read it.","I'm nice at ping pong","The media tries to kill our heroes one at a time","All you have to be is yourself"]
    
    # If you don't provide a valid API token, unauthorized response is give
    curl -k -H "Accept: application/json" https://localhost/api/quotes
    {"message":"Unauthenticated."}
    

Cheat sheet

Back end:

# Use composer
docker-compose exec php composer install
docker-compose exec php composer update
docker-compose exec php composer require --dev foo/bar

# Run tests
docker-compose exec php composer run test

# Run phpstan
docker-compose exec php composer run phpstan

# Run php-cs-fixer
docker-compose exec php composer run php-cs-fixer

# Run phpcs
docker-compose exec php composer run phpcs

kanye-api's People

Contributors

philbates35 avatar

Watchers

 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.