Giter VIP home page Giter VIP logo

hso-test's Introduction

About

This a test API which has accounts, orders and products functionality.

It also makes use of the laravel passport module to authenticate users.

The functionality is very basic but demonstrates how results can be paginted when being passed on to a front-end app like vue or react.

The has full CRUD functionality

The Account and Order models have a one to many relationship respectively.

The Product and Order models have this too.

The relationships does not have any foreign key constraints on the database level but can be added if need be by creating an update migration.

How to run the app

Step 1 Clone the the repo or copy to your hosting folder

Step 2 Navigate to the app folder

Step 3 Run 'Composer dump-autoload

Step 4 Create a database in your database

Step 5 Add database details to the .env file Add PAGE_SIZE constant to .env file and set value according to how many items you want displayed per page

Step 6 Run command 'php artisan migrate'

Step 6 Run command 'php artisan db:seed'

Step 7 Run command 'php artisan serve'

Available routes

User routes (POST)
http://127.0.0.1:8000/api/register
http://127.0.0.1:8000/api/login

Account routes (GET)
http://127.0.0.1:8000/api/accounts
http://127.0.0.1:8000/api/accounts/1
Account routes (POST)
http://127.0.0.1:8000/api/accounts
Account routes (PUT) & (DELETE)
http://127.0.0.1:8000/api/accounts/1

Orders routes (GET)
http://127.0.0.1:8000/api/orders
http://127.0.0.1:8000/api/account_orders/1
http://127.0.0.1:8000/api/orders/1
Orders routes (POST)
http://127.0.0.1:8000/api/orders
Orders routes (PUT) & (DELETE)
http://127.0.0.1:8000/api/orders/1

Products routes (GET)
http://127.0.0.1:8000/api/products
http://127.0.0.1:8000/api/products/1
Account routes (POST)
http://127.0.0.1:8000/api/products
Account routes (PUT) & (DELETE)
http://127.0.0.1:8000/api/products/1

Authentication

The API routes are are all behind a middleware that requires users to be signed in. The seed creates a user whose login details are email = [email protected] & password = password use these details to login here http://127.0.0.1:8000/api/login by passing the 2 params using a client such as insomnia or postman Once authenticated a bearer token will be returned and this should be passed in the header when making requested to the API

If the login details provided do not work you can use the http://127.0.0.1:8000/api/register route to create another account.

hso-test's People

Contributors

wizdom75 avatar

Watchers

 avatar James Cloos 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.