Skip to content

Commit

Permalink
docs(#SAM-337): Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
roosiu committed Oct 24, 2024
1 parent 8560b6f commit c74d223
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Remember to put repository in a composer.json

Functionalities are organized into packages within the src/Bundles folder:

- [Auth](#Auth)
- [AuthorizedRequest](#AuthorizedRequest)
- [TrustOnlyAuthenticated](#TrustOnlyAuthenticated)
- [Middleware](#middleware)
- [LocalizationMiddleware](#LocalizationMiddleware)
- [ForceJsonMiddleware](#ForceJsonMiddleware)
Expand All @@ -45,6 +48,26 @@ Functionalities are organized into packages within the src/Bundles folder:

---

## Auth

### AuthorizedRequest

The trait is used in request classes to automatically check if a user is authorized to perform a given action.
It ensures that only authenticated users can proceed with the request.

### TrustOnlyAuthenticated

The middleware checks if the authenticated user’s UUID matches the UUID in the route

example:

```php
Route::middleware(TrustOnlyAuthenticated::class)->group(function () {
Route::post('/user/{uuid}/update', [UserController::class, 'update']);
```

---

## Middleware

### LocalizationMiddleware
Expand All @@ -59,6 +82,7 @@ Route::middleware(LocalizationMiddleware::class)->get('/', [MyController::class,
```

### ForceJsonMiddleware

This middleware changes the `accept: *` header to `accept: application/json`.

example:
Expand All @@ -77,7 +101,8 @@ Route::middleware(ForceJsonMiddleware::class)->get('/', [MyController::class, 'i

### ApiCollection

Used to return a collection of models in an API response. Extends the ResourceCollection by providing additional information
Used to return a collection of models in an API response. Extends the ResourceCollection by providing additional
information
to the API response

### ApiResource
Expand All @@ -86,8 +111,8 @@ extends JsonResource

- `whenHasAttribute()` Checks if the resource has the specified attribute.
- `noContent()` - Allows the response to be returned with an HTTP 204 (No Content) status code.
---

---

## ValueObject

Expand Down

0 comments on commit c74d223

Please sign in to comment.