Code Monkey home page Code Monkey logo

artists-test's Introduction

Artists-test

Endpoints:

All artists
GET http://artists.test/api/v1/artists => all artists

Artists filter by active/inactive
GET http://artists.test/api/v1/artists?filter[inactive] => inactive
GET http://artists.test/api/v1/artists?filter[active] => active

Artists filter by email
GET http://artists.test/api/v1/artists?filter[email]=some_email => email

Error wrapped by Laravel's collection
GET http://artists.test/api/v1/artists?filter[ohmyerror] => error response with 400 HTTP code I didn't add any custom wrapper as Laravel has built-in if we use Collections.

API has Basic authorization, so pass Authorization: Basic development-pass header in your requests. Check tests/HTTP/artists.http for request examples.

** You can replace artists.test with localhost if you host on 80 port. If port is different from 80, use localhost:<port>.

All endpoints are paginated and wrapped as a Laravel collection, so the frontend part should use it without any issues.

If you use JetBrains production, such as PHPStorm, you can just right into ./tests/HTTP/artists.http file to run HTTP requests right from the IDE (don't forget to select the dev environment located in ./tests/HTTP/http-client.env.json).

Rollup local build:

Clone this repository:

git clone https://github.com/tlishchynskiy/artists-test
cd artists-test

And follow the instructions below:

If you have make and docker/podman-compose installed: ** For immutable linux distros with pre-installed OCI containers, install podman-compose using rpm-ostree or similar.

make rollup

** Please don't forget about privileged ports and rootless setup, so it may throw an error if you are trying to build rootless compose without any configuration on your end.

** If make rollup failed on database migration (db container is not booted at that moment), then type these commands manually:

make migrate
make seed

And you are good to do ;)

To enter the PHP container, run make php, then you are able to run compose/npm commands.

Otherwise, here are steps to rollup your local without make or docker/podman-compose

  1. cp .env.example .env
  2. composer install
  3. php artisan key:generate
  4. npm install && npm run dev (optional)
  5. Add database credentials to .env file
  6. php artisan migrate
  7. php artisan db:seed
  8. php artisan serve

If you want to add local domain to hosts file, you can run make command or add it manually:

  • sudo make add-host
  • Manually: add 127.0.0.1 artists.test to /etc/hosts file.

Files changed/added:

app/Http/Controllers/api/v1/ArtistsController.php
app/Http/Resources/ArtistCollection.php

database/factories/ArtistFactory.php database/migrations/2024_02_05_132158_create_artists_table.php database/seeders/ArtistsSeeder.php

routes/api/v1.php

tests/HTTP/artists.http
tests/HTTP/http-client.env.json

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.