Skip to content

cmeza/poll-app-challenge

Repository files navigation

Poll Coding Challenge

NOTE

  • Other than the /dashboard, /register, /login routes, none of the UI is complete as of Nov 11 9am. The only functionality is the API.

Project Setup

  • Clone this repo: git clone [email protected]:cmeza/poll-app-challenge.git
  • Copy the .env.example, paste as .env, there are TWO env files
    • ./.env (Docker specific config)
    • ./laravel/.env (Laravel specific config)
  • Edit the .env with your values
  • Start the Docker containers: docker-compose up -d
  • Connect to the app container: docker-compose exec app bash
    (Steps after this are completed in the app container CLI)
  • Install the PHP dependencies: composer install
  • Install the JS dependencies: npm install
  • Install the Laravel application key: php artisan key:generate --ansi
  • Run the migrations: php artisan migrate
  • Setup the initial data: php artisan db:seed
  • Edit your hosts file to include: 127.0.0.1 pollapp.test
  • Generate API tokens with in the Poll App UI

Tinker with the App

You will need to register to do anything with the app.

Wep/API Routes

You can view the following routes without any authentication and from the browser.

PRO TIP: install the JSONViewer browser extension to view formatted JSON in the browser!

  • View the existing routes: php artisan route:list
    • Unauthenticated API routes:
      • GET /api/polls
      • GET /api/polls/{poll}
      • GET /api/questions
      • GET /api/questions/{question}
      • GET /api/results
      • GET /api/results/{result}
      • GET /api/types
      • GET /api/types/{type}
    • Authenticated API routes:
      • POST /api/polls
      • PATCH /api/polls/{poll}
      • DELETE /api/polls/{poll}
      • POST /api/questions
      • PATCH /api/questions/{question}
      • DELETE /api/questions/{question}
      • POST /api/results
      • PATCH /api/results/{result}
      • DELETE /api/results/{result}
      • POST /api/types
      • PATCH /api/types/{type}
      • DELETE /api/types/{type}

API Tokens

To access the API, you will need some Bearer Tokens generated by the Sanctum library.

Generate tokens:
Generate API Tokens

  • Click your name to access profile menu
  • Click API Tokens
  • Create 2 tokens (the names are arbitrary), copy each one as you will only see it once
    • Generate one with just read permission checked
    • Generate another with all permissions checked
  • Import the Poll App Postman environment/collection from the project root & make calls.
    • Paste those tokens into the Postman variables for read only in pollTokenRead, the other in pollTokenFull
      Postman environment variables
    • The read only token should not be able to create/update/delete any resources
    • The other token should be able to do all resource actions
    • To test authorization on a specific create/update/delete route in Postman:
      Postman per request Authorization
      1. Click the Authorization tab
      2. Change the TYPE from Inherit auth from parent to Bearer Token
      3. Set Token to {{pollTokenRead}}
      4. When you're done testing the read only, switch the TYPE back to Inherit auth from parent
      5. This {{pollTokenRead}} should be there each time you change the setting on any other routes now too!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages