mirror of
https://github.com/pockethost/pockethost.git
synced 2025-03-30 15:08:30 +00:00
1.1 KiB
1.1 KiB
Creating RPC Calls
For security, PocketHost does not allow modification of records by the frontend PocketBase client. Instead, the frontend must send an rpc request which the backend will securely process. This allows for many security vulnerabilities to be addressed which PocketBase admin security rules cannot. In particular, PocketBase admin security rules fall short in these scenarios:
- When the incoming data cannot be validated declaratively
- When multiple records and/or tables must be updated as a transaction
- When side-effects (ie, other mutations) are required under specific conditions
Therefore, PocketHost uses an RPC pattern instead.
Creating a new RPC Call
- Create a new RPC call in
./packages/common/schema/Rpc
- Add frontend support in
./packages/pockethost.io/src/pocketbase/PocketbaseClient.ts
using themkRpc
command - Add backend support in (for example)
./packages/daemon/src/services/InstanceService/InstanceService.ts
usingregisterCommand
Getting the result from an RPC call
RPC results are currently not supported. RPC commands are run asynchronously.