rest-vir - v1.0.0
    Preparing search index...

    Type Alias MinimalService<ServiceName>

    This is a minimal service definition with only data to send and handle fetch requests to that service. Each endpoint definition gets a copy of this embedded into it so the endpoint alone can be used as an input to the endpoint fetch function.

    type MinimalService<ServiceName extends string = string> = {
        requiredClientOrigin: NonNullable<OriginRequirement>;
        serviceName: IsEqual<ServiceName, ""> extends true ? never : ServiceName;
        serviceOrigin: string;
    }

    Type Parameters

    • ServiceName extends string = string
    Index

    Properties

    requiredClientOrigin: NonNullable<OriginRequirement>

    The service's origin requirement for all endpoint requests and WebSocket connections. This is used for CORS handshakes.

    This can be a string, a RegExp, a function, or an array of any of those. (If this is an array, the first matching array element will be used.)

    Set this to AnyOrigin (imported from '@rest-vir/define-service') to allow any origins. Make sure that you're okay with the security impact this may have on your users of doing so.

    serviceName: IsEqual<ServiceName, ""> extends true ? never : ServiceName
    serviceOrigin: string

    The origin at which the service will be hosted. Fetch requests and WebSocket connections will be sent to this service will be sent to this origin.

    It is recommended to use a ternary to switch between dev and prod origins.

    import {defineService} from '@rest-vir/define-service';

    defineService({
    serviceOrigin: isDev ? 'http://localhost:3000' : 'https://example.com',
    });

    https://developer.mozilla.org/en-US/docs/Web/API/Location for help on which part of the URL is the origin (if necessary).