@squidcloud/backend
    Preparing search index...

    Class SquidService

    A base class for all the different types of Squid backend services. This class serves as a container for the various methods implemented in the backend in order to customize the Squid backend for an application.

    Index

    Accessors

    • get apiKeys(): Record<string, string>

      The list of your application's api keys.

      Returns Record<string, string>

    • get assetsDirectory(): string

      Returns the assets directory for your application.

      Returns string

      the assets directory for your application.

    • get context(): RunContext

      The context object for the current request. This object contains information about the current request, such as the current user, the IP address, the user agent used, the request headers, and more.

      Returns RunContext

    • get secrets(): Record<string, SecretValue>

      The list of your application's secrets as defined in the Squid Console.

      Returns Record<string, SecretValue>

    • get squid(): Squid

      Returns the Squid client instance for your application.

      Returns Squid

      the Squid client instance for your application.

    Constructors

    Methods

    • Asserts that the current method call includes an API key in the context. Throws an error if called without an API key.

      Returns void

    • Asserts that the method is called within a valid request scope. Throws an error if no request context can be found.

      Returns void

    • Asserts that the current request is authenticated (using a user token or an API key).

      Returns void

      UNAUTHORIZED if the current request is not authenticated.

    • Converts a file to a SquidFile object. This function is useful when you want to return a file using OpenAPI (tsoa decorators).

      Parameters

      • file: File

      Returns Promise<SquidFile>

    • Constructs a response for an OpenAPI operation. This function is typically used within an OpenAPI handler.

      Parameters

      • Optionalbody: unknown

        The payload of the response. If not provided, defaults to an empty string.

      • OptionalstatusCode: number

        The HTTP status code for the response. Defaults to 200 if a body is present, otherwise 204.

      • Optionalheaders: Record<string, unknown>

        An object containing response headers. Defaults to an empty object if not provided.

      Returns any

      The openapi response.

    • A helper method to create a webhook response. This method should be used inside a webhook handler (function decorated with @webhook).

      Parameters

      • Optionalbody: unknown

        The body of the response.

      • OptionalstatusCode: number

        The status code of the response.

      • Optionalheaders: Record<string, unknown>

        The headers of the response.

      Returns any

      The webhook response.

    • Returns the API key used by the backend for your application.

      Returns string

    • Returns the auth object for the current request or undefined if unauthenticated or if using a user token.

      Returns undefined | AuthWithApiKey

      The auth object for the current request or undefined if unauthenticated or if using a user token.

    • Returns the auth object for the current request or undefined if unauthenticated or if using an API key.

      Returns undefined | AuthWithBearer

      The auth object for the current request or undefined if unauthenticated or if using an API key.

    • Returns true if the current request is authenticated (using a user token or an API key).

      Returns boolean

      true if the current request is authenticated (using a user token or an API key).

    • Throws an OpenAPI response. This function is useful when you want to interrupt normal execution and immediately return a response from an OpenAPI handler.

      Parameters

      • content: Partial<{ body: unknown; headers: Record<string, unknown>; statusCode: number }>

        The response content including optional body, status code, and headers.

      Returns never

      An object marked as an OpenAPI response.

    • Throws a webhook response. This function is useful when you want to interrupt normal execution and immediately return a response from a webhook handler.

      Parameters

      • content: Partial<{ body: unknown; headers: Record<string, unknown>; statusCode: number }>

        The response content including optional body, status code, and headers.

      Returns never

      An object marked as a webhook response.

    Properties

    backendBaseUrl: string
    region: "us-east-1.aws" | "ap-south-1.aws" | "us-central1.gcp" = ...

    Your application's region. When developing locally, the region will be set to local.