diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c13160b..1fc9023 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,5 +51,8 @@ jobs: - name: Generate Application Key run: php artisan key:generate + - name: Generate OAuth2 Keys + run: php artisan passport:keys + - name: Tests run: ./vendor/bin/pest diff --git a/README.md b/README.md new file mode 100644 index 0000000..c6a05df --- /dev/null +++ b/README.md @@ -0,0 +1,127 @@ +# Key-Value Versions + +## Local Setup + +- `git clone https://github.com/dumindu/key-value-versions.git` +- `cd key-value-versions/key-value-versions-app` +- `composer install` +- `npm install && npm run build` +- `cp .env.example .env` +- `php artisan key:generate` +- `php artisan passport:keys` +- ` ./vendor/bin/sail up` +- `./vendor/bin/sail artisan migrate` + +> 💡 Need to run Docker. + +## Web Dashboard + +![Laravel Web Dashboard](key-value-versions-app/public/images/web-dashboard.png) + +### Pages + +- Register +- Login +- Profile Settings + +## API Endpoints + +> Use [Yaak](https://yaak.app) to access the Open API documentation/ setup in the [__openapi](__openapi) folder. + +### 1. User Registration + +#### Endpoint + +`[POST] api/v1/register` + +#### Headers + +- Accept: `application/json` + +#### Request Body + +```json +{ + "name": "User Name", + "email": "user@email.com", + "password": "some_password", + "password_confirmation": "some_password" +} +``` + +### 2. Get Oauth2 Tokens + +#### Endpoint + +`[POST] oauth/token` + +#### Headers + +- Accept: `application/json` + +#### Request Body + +```json +{ + "grant_type": "password", + "client_id": "01989503-1ce8-735f-a487-0729ef4f1d1b", + "client_secret": "WqkuICsupCfBL1xLt71TfBSaaLVlaiTd0iMSudpu", + "username": "user@email.com", + "password": "some_password", + "scope": "*" +} +``` + +### 3. Create New Key/Value + +#### Endpoint + +`[POST] /api/v1/keys` + +#### Headers + +- Accept: `application/json` +- Authorization: `Bearer ` + +#### Request Body + +```json +{ + "key": "001", + "value": "value 001" +} +``` + +### 4. Get All Keys With Latest Values + +#### Endpoint + +`[GET] /api/v1/keys` + +#### Headers + +- Accept: `application/json` +- Authorization: `Bearer ` + +### 5. Get A Key With Latest Value + +#### Endpoint + +`[GET] /api/v1/keys/{key}` + +#### Headers + +- Accept: `application/json` +- Authorization: `Bearer ` + +### 6. Get A Key With All Values + +#### Endpoint + +`[GET] /api/v1/keys/{key}/history` + +#### Headers + +- Accept: `application/json` +- Authorization: `Bearer ` + diff --git a/key-value-versions-app/app/Http/Middleware/ForceJsonResponse.php b/key-value-versions-app/app/Http/Middleware/ForceJsonResponse.php new file mode 100644 index 0000000..acb58fe --- /dev/null +++ b/key-value-versions-app/app/Http/Middleware/ForceJsonResponse.php @@ -0,0 +1,22 @@ +headers->set('Accept', 'application/json'); + + return $next($request); + } +} diff --git a/key-value-versions-app/bootstrap/app.php b/key-value-versions-app/bootstrap/app.php index 2f7d821..e4fd18a 100644 --- a/key-value-versions-app/bootstrap/app.php +++ b/key-value-versions-app/bootstrap/app.php @@ -1,5 +1,6 @@ api(append: [ + ForceJsonResponse::class, + ]); }) ->withExceptions(function (Exceptions $exceptions) { // diff --git a/key-value-versions-app/public/images/web-dashboard.png b/key-value-versions-app/public/images/web-dashboard.png new file mode 100644 index 0000000..0a87ab8 Binary files /dev/null and b/key-value-versions-app/public/images/web-dashboard.png differ