mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
wip
This commit is contained in:
4
docs/extending-the-server/_index.md
Normal file
4
docs/extending-the-server/_index.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
title: Extending The Server
|
||||
order: 5
|
||||
---
|
||||
43
docs/extending-the-server/subdomain-generator.md
Normal file
43
docs/extending-the-server/subdomain-generator.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: Subdomain Generator
|
||||
order: 1
|
||||
---
|
||||
|
||||
# Subdomain Generator
|
||||
|
||||
When a user does not explicitly specify a custom subdomain, the expose server takes care of generating a random unique subdomain.
|
||||
|
||||
The default generator looks like this:
|
||||
|
||||
```php
|
||||
use Illuminate\Support\Str;
|
||||
use App\Contracts\SubdomainGenerator;
|
||||
|
||||
class RandomSubdomainGenerator implements SubdomainGenerator
|
||||
{
|
||||
public function generateSubdomain(): string
|
||||
{
|
||||
return strtolower(Str::random(10));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
It simply generates a random lowercase string.
|
||||
|
||||
You can create your own custom subdomain generator class, by implementing the `SubdomainGenerator` interface.
|
||||
|
||||
Next you need to specify your custom subdomain generator in your expose configuration file:
|
||||
|
||||
```php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Subdomain Generator
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the subdomain generator that will be used, when no specific
|
||||
| subdomain was provided. The default implementation simply generates
|
||||
| a random string for you. Feel free to change this.
|
||||
|
|
||||
*/
|
||||
'subdomain_generator' => \App\Server\SubdomainGenerator\RandomSubdomainGenerator::class,
|
||||
```
|
||||
29
docs/extending-the-server/user-repository.md
Normal file
29
docs/extending-the-server/user-repository.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: User Repository
|
||||
order: 2
|
||||
---
|
||||
|
||||
# User Repository
|
||||
|
||||
The expose server tries to load users out of the built-in SQLite database by default.
|
||||
|
||||
If you want to change the default implementation and load your users from a different storage engine, you can implement the `UserRepository` interface and change it in your expose configuration file.
|
||||
|
||||
This is how the interface looks like:
|
||||
|
||||
```php
|
||||
use React\Promise\PromiseInterface;
|
||||
|
||||
interface UserRepository
|
||||
{
|
||||
public function getUsers(): PromiseInterface;
|
||||
|
||||
public function getUserById($id): PromiseInterface;
|
||||
|
||||
public function getUserByToken(string $authToken): PromiseInterface;
|
||||
|
||||
public function storeUser(array $data): PromiseInterface;
|
||||
|
||||
public function deleteUser($id): PromiseInterface;
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user