Skip to content

eerzho/vanilla_php

Repository files navigation

test_slotegrator

Project deployment instructions:

  1. Clone the project.
  2. Copy the file env.example.php to the root of the project and name it env.php.
  3. Run the command composer install.
  4. Run the command php -S localhost:8000
  5. Run the command php run-migrations.php
  6. Run the command php run-seeders.php

Routes:

Users management:
POST: /user
AUTH: false
DESCRIPTION: New user registration
BODY: {
  name: 'required', 'str', 'min:3', 'max:255',
  email: 'required', 'email',
  password: 'required', 'str', 'min:8', 'max:255'
}

POST: /auth/login
AUTH: false
DESCRIPTION: Login
BODY: {
  email: 'required', 'email',
  password: 'required', 'str', 'min:8', 'max:255'
}

GET: /auth/me
AUTH: true
DESCRIPTION: Get auth user

GET: /user
AUTH: true
DESCRIPTION: Get all users
QUERY: {
   sort: id, -id, created_at, -created_at
   search: [id, email, name]
}

GET: /user/:id
AUTH: true
DESCRIPTION: Get one user

PUT: /user/:id
AUTH: true
DESCRIPTION: Update user
BODY: {
  name: 'required', 'str', 'min:3', 'max:255',
  email: 'required', 'email',
  password: 'required', 'str', 'min:8', 'max:255'
}

DELETE: /user/:id
AUTH: true
DESCRIPTION: Delete user

Products management (физический предмет): GET: /product
AUTH: true
DESCRIPTION: Get all products
QUERY: {
   sort: id, -id, count, -count
   search: [id, name, count]
}

POST: /product
AUTH: true
DESCRIPTION: Create new product
BODY: {
  name: 'required', 'str', 'min:3', 'max:255',
  description: 'required', 'str', 'min:3', 'max:255',
  count: 'required', 'int', 'min:2', 'max:200'
}

GET: /product/:id
AUTH: true
DESCRIPTION: Get one product

PUT: /product/:id
AUTH: true
DESCRIPTION: Update product
BODY: {
  name: 'required', 'str', 'min:3', 'max:255',
  description: 'required', 'str', 'min:3', 'max:255',
  count: 'required', 'int', 'min:2', 'max:200'
}

Monetary management (случайная сумма в интервале): GET: /monetary
AUTH: true
DESCRIPTION: Get all monetary
QUERY: {
   sort: id, -id, type, -type
   search: [id, type]
}

POST: /monetary
AUTH: true
DESCRIPTION: Create new monetary
BODY: {
   type: bonus or real money,
   max_sum: 'int', 'min:1'
   interval_from: 'required', 'int', 'min:1', 'max:interval_to'
   interval_to: 'required', 'int', 'min:interval_from', 'max:max_sum'
}

GET: /monetary/:id
AUTH: true
DESCRIPTION: Get one monetary

PUT: /monetary/:id
AUTH: true
DESCRIPTION: Update monetary
BODY: {
   max_sum: 'int', 'min:1'
   interval_from: 'required', 'int', 'min:1', 'max:interval_to'
   interval_to: 'required', 'int', 'min:interval_from', 'max:max_sum'
}

Prize (Призы): GET: /prize
AUTH: true
DESCRIPTION: Get all prizes
QUERY: {
   sort: id, -id
   search: [target_id, type, user_id]
}

POST: /prize
AUTH: true
DESCRIPTION: To receive a prize

GET: /prize/:id
AUTH: true
DESCRIPTION: Get one prize

DELETE: /prize/:id
AUTH: true
DESCRIPTION: Waiver of a prize

POST: /prize/:id/convert
AUTH: true
DESCRIPTION: Real money convert to bonus


Commands:

NAME: php run-migrations.php
DESCRIPTION: Runs all migrations from database/migrations directories

NAME: php run-seeders.php
DESCRIPTION: Runs all seeders from database/seeders directories

NAME: php send-bonus.php
DESCRIPTION: Accrues bonuses to users

NAME: php drop-migrations.php
DESCRIPTION: Drop all tables from db

NAME: ./vendor/bin/phpunit
DESCRIPTION: Runs all test


Additionally:

Project in Insomnia: insomnia_project.json
Request example:
img.png

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages