Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create API and adapt to Kotlin Client #1

Merged
merged 16 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 26 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"intelephense.environment.documentRoot": "./api"
}
18 changes: 18 additions & 0 deletions api/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[docker-compose.yml]
indent_size = 4
64 changes: 64 additions & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
11 changes: 11 additions & 0 deletions api/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.github export-ignore
CHANGELOG.md export-ignore
.styleci.yml export-ignore
19 changes: 19 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode
40 changes: 40 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Shared Calendar App API

This is the API for the Shared Calendar App. It is built with Laravel.

## Requirements

- PHP 7.4
- Composer
- MySQL
- Laravel

## Installation

To install the dependencies, run the following command:

```bash
composer install
```

To create the database, run the following command:

```bash
php artisan migrate
```

To start the server, run the following command:

```bash
php artisan serve
```

To run the tests, run the following command:

```bash
php artisan test
```

## API Endpoints

You can find the documentation for the API endpoints on <http://localhost:8000/docs/api> after starting the server.
30 changes: 30 additions & 0 deletions api/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Exceptions;

use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{

/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
// This will replace our 404 response with
// a JSON response.
$this->renderable(function (ModelNotFoundException $e, $request) {
return response()->json([
'error' => 'Resource not found'
], 404);
});


$this->reportable(function (Throwable $e) {
//
});
}
}
87 changes: 87 additions & 0 deletions api/app/Http/Controllers/Api/AccountController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Account;
use Illuminate\Http\Request;


/**
* APIs for managing user accounts
*/
class AccountController extends Controller
{
/**
* Get All Accounts
*
* Display a listing of the account.
*/
public function index()
{
$accounts = Account::all();
return $accounts;
}

/**
* Show the form for creating a new account.
*/
public function create()
{
//
}

/**
* Create and Save new Account
*
* Store a newly created account in database.
*
* @apiResourceModel App\Models\Account
*/
public function store(Request $request)
{
$account = Account::create($request->all());

return response()->json($account, 201);
}

/**
* Get Account by ID
*
* Display the specified account.
*/
public function show(Account $account)
{
return $account;
}

/**
* Show the form for editing the specified account.
*/
public function edit(Account $account)
{
//
}

/**
* Update Account By ID
*
* Update the specified account in database.
*/
public function update(Request $request, Account $account)
{
$account->update($request->all());
return response()->json($account, 200);
}

/**
* Delete Account By ID
*
* Remove the specified account from database.
*/
public function destroy(Account $account)
{
$account->delete();
return response()->json(null, 204);
}
}
Loading