Original task (all requirments are competed) https://gist.github.com/f1uder/91f428ceedcc7ea8ef66a71b2128b9f7
- Route::resource
- UserController
- Form Verification
- Tests
- Schedule (cron)
- Queues (jobs/workers, async/microservice communication)
- Commands (cli)
- Object cache
- Push (Websockets)
- Docker Compose
- WSL2 (for Windows)
- free 8080 port
Note: On Windows you must use WSL2.
Clone main
branch from the repository:
git clone https://github.com/b9sk/interview_task_sec.git -b main
Copy .env.example
to .env
.
Run docker compose up -d
and wait for the containers to be ready.
Run ./composer.sh install
.
Create tables and populate users with test data from UserSeeder:
./artisan.sh migrate --seed
.
Run ./artisan.sh test
, pass all tests.
Go to http://localhost:8080, get 200.
{{HOST}} = http://localhost:8080
- URL:
/api/users
- Method:
GET
- Query Parameters:
page
(optional): Page number for pagination.name
(optional): Filter users by name.order
(optional): Order by name, values can beasc
ordesc
.
- Response:
- Status:
200 OK
- Body:
{ "data": [ { "id": 1, "name": "John Doe", "email": "john@example.com", "created_at": "2023-01-01T00:00:00.000000Z", "updated_at": "2023-01-01T00:00:00.000000Z" }, ... ], "links": { "first": "...", "last": "...", "prev": null, "next": "..." }, "meta": { "current_page": 1, "from": 1, "last_page": 1, "path": "...", "per_page": 20, "to": 1, "total": 1 } }
- Status:
- URL:
/api/users/{id}
- Method:
GET
- Response:
- Status:
200 OK
- Body:
{ "id": 1, "name": "John Doe", "email": "john@example.com", "created_at": "2023-01-01T00:00:00.000000Z", "updated_at": "2023-01-01T00:00:00.000000Z" }
- Status:
- URL:
/api/users
- Method:
POST
- Body:
{ "name": "John Doe", "email": "john@example.com", "password": "password", "comment": "This is a comment", "ip": "127.0.0.1" }
- Response:
- Status:
201 Created
- Body:
{ "id": 1, "name": "John Doe", "email": "john@example.com", "created_at": "2023-01-01T00:00:00.000000Z", "updated_at": "2023-01-01T00:00:00.000000Z" }
- Status:
- URL:
/api/users/{id}
- Method:
PUT
- Body:
{ "name": "John Doe", "password": "newpassword" }
- Response:
- Status:
200 OK
- Body:
{ "id": 1, "name": "John Doe", "email": "john@example.com", "created_at": "2023-01-01T00:00:00.000000Z", "updated_at": "2023-01-01T00:00:00.000000Z" }
- Status:
- URL:
/api/users/{id}
- Method:
DELETE
- Response:
- Status:
204 No Content
- Status:
curl -X GET "{{HOST}}/api/users?page=1"
curl -X GET "{{HOST}}/api/users/1"
curl -X POST "{{HOST}}/api/users" -H "Content-Type: application/json" -d '{
"name": "John Doe",
"email": "john@example.com",
"password": "password",
"comment": "This is a comment",
"ip": "127.0.0.1"
}'
curl -X PUT "{{HOST}}/api/users/1" -H "Content-Type: application/json" -d '{
"name": "John Doe",
"password": "newpassword"
}'
curl -X DELETE "{{HOST}}/api/users/1"