mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
add remote provider docs
This commit is contained in:
parent
fba7d1d77d
commit
9f61258e74
@ -10,4 +10,12 @@ tags:
|
||||
|
||||
# Remote Strapi Providers
|
||||
|
||||
**TODO**
|
||||
Remote Strapi providers connect to an instance of Strapi over a network using a websocket.
|
||||
|
||||
Internally, the remote Strapi providers map websocket requests to a local Strapi provider of the instance it is running in.
|
||||
|
||||
## Websocket Server
|
||||
|
||||
When the data transfer feature is enabled for a Strapi server (a transfer token salt has been set on the server and STRAPI_DISABLE_REMOTE_DATA_TRANSFER is not set to true), Strapi will create websocket servers available on the routes `/admin/transfer/runner/pull` and `/admin/transfer/runner/push`.
|
||||
|
||||
Opening a websocket connection on those routes requires a valid transfer token as a bearer token in the Authorization header.
|
||||
|
||||
@ -8,4 +8,23 @@ tags:
|
||||
|
||||
# Strapi Remote Source Provider
|
||||
|
||||
**TODO**
|
||||
The Strapi remote source provider connects to a remote Strapi websocket server and sends messages to move between stages and pull data.
|
||||
|
||||
## Provider Options
|
||||
|
||||
The remote source provider accepts a `url` and `auth` options described below.
|
||||
|
||||
```typescript
|
||||
interface ITransferTokenAuth {
|
||||
type: 'token';
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface IRemoteStrapiDestinationProviderOptions
|
||||
extends Pick<ILocalStrapiDestinationProviderOptions, 'restore' | 'strategy'> {
|
||||
url: URL;
|
||||
auth?: ITransferTokenAuth;
|
||||
}
|
||||
```
|
||||
|
||||
Note: `url` must include the protocol `https` or `http` which will then be converted to `wss` or `ws` to make the connection. A secure connection is strongly recommended, especially given the high access level that the transfer token provides.
|
||||
|
||||
@ -8,4 +8,23 @@ tags:
|
||||
|
||||
# Strapi Remote Destination Provider
|
||||
|
||||
**TODO**
|
||||
The Strapi remote destination provider connects to a remote Strapi websocket server and sends messages to move between stages and push data.
|
||||
|
||||
## Provider Options
|
||||
|
||||
The remote destination provider accepts the same `restore` and `strategy` options from local Strapi destination provider, plus `url` and `auth` options described below.
|
||||
|
||||
```typescript
|
||||
interface ITransferTokenAuth {
|
||||
type: 'token'; // the name of the auth strategy
|
||||
token: string; // the transfer token
|
||||
}
|
||||
|
||||
export interface IRemoteStrapiDestinationProviderOptions
|
||||
extends Pick<ILocalStrapiDestinationProviderOptions, 'restore' | 'strategy'> {
|
||||
url: URL; // the url of the remote Strapi admin
|
||||
auth?: ITransferTokenAuth;
|
||||
}
|
||||
```
|
||||
|
||||
Note: `url` must include the protocol `https` or `http` which will then be converted to `wss` or `ws` to make the connection. A secure connection is strongly recommended, especially given the high access level that the transfer token provides.
|
||||
|
||||
@ -6,20 +6,15 @@ import { once } from 'lodash/fp';
|
||||
import { createDispatcher, connectToWebsocket, trimTrailingSlash } from '../utils';
|
||||
|
||||
import type { IDestinationProvider, IMetadata, ProviderType, IAsset } from '../../../../types';
|
||||
import type { client, server } from '../../../../types/remote/protocol';
|
||||
import type { client, server, auth } from '../../../../types/remote/protocol';
|
||||
import type { ILocalStrapiDestinationProviderOptions } from '../local-destination';
|
||||
import { TRANSFER_PATH } from '../../remote/constants';
|
||||
import { ProviderTransferError, ProviderValidationError } from '../../../errors/providers';
|
||||
|
||||
interface ITransferTokenAuth {
|
||||
type: 'token';
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface IRemoteStrapiDestinationProviderOptions
|
||||
extends Pick<ILocalStrapiDestinationProviderOptions, 'restore' | 'strategy'> {
|
||||
url: URL;
|
||||
auth?: ITransferTokenAuth;
|
||||
url: URL; // the url of the remote Strapi admin
|
||||
auth?: auth.ITransferTokenAuth;
|
||||
}
|
||||
|
||||
const jsonLength = (obj: object) => Buffer.byteLength(JSON.stringify(obj));
|
||||
|
||||
@ -10,20 +10,15 @@ import type {
|
||||
ProviderType,
|
||||
TransferStage,
|
||||
} from '../../../../types';
|
||||
import { client, server } from '../../../../types/remote/protocol';
|
||||
import { client, server, auth } from '../../../../types/remote/protocol';
|
||||
import { ProviderTransferError, ProviderValidationError } from '../../../errors/providers';
|
||||
import { TRANSFER_PATH } from '../../remote/constants';
|
||||
import { ILocalStrapiSourceProviderOptions } from '../local-source';
|
||||
import { createDispatcher, connectToWebsocket, trimTrailingSlash } from '../utils';
|
||||
|
||||
interface ITransferTokenAuth {
|
||||
type: 'token';
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface IRemoteStrapiSourceProviderOptions extends ILocalStrapiSourceProviderOptions {
|
||||
url: URL;
|
||||
auth?: ITransferTokenAuth;
|
||||
url: URL; // the url of the remote Strapi admin
|
||||
auth?: auth.ITransferTokenAuth;
|
||||
}
|
||||
|
||||
class RemoteStrapiSourceProvider implements ISourceProvider {
|
||||
|
||||
4
packages/core/data-transfer/types/remote/protocol/auth.d.ts
vendored
Normal file
4
packages/core/data-transfer/types/remote/protocol/auth.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export interface ITransferTokenAuth {
|
||||
type: 'token'; // the name of the auth strategy
|
||||
token: string; // the transfer token
|
||||
}
|
||||
@ -1,2 +1,3 @@
|
||||
export * as client from './client';
|
||||
export * as server from './server';
|
||||
export * as auth from './auth';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user