Skip to main content

Forge Bridge API for backend FaaS functions

Inside Forge backend FaaS function modules (like Web Trigger, Custom Fields, Workflow extensions), you can use these global bridge objects and functions from '@forge/api' to access your application:

API​

  • api: The api provides access to both requestJira and requestConfluence, which allow you to access data from your application through the REST API.

  • route: To construct the path passed to the product fetch APIs, you must use the route tagged template function. This function blocks unsafe interpolated parameters in the path and encodes the query parameters using encodeURIComponent. This ensures protection against security vulnerabilities like path traversal and query string injection.

  • fetch: The Forge Fetch API is a partial implementation of node-fetch, which fetches data from an HTTP server. In its simplest form, fetch acts as a basic HTTP client.

  • authorize: The Forge Authorize API helps app developers verify user permissions before making requests using the asApp method.

  • request: "request" is an object sent to your backend function from an external caller. It contains all the information about the request, such as query parameters, headers, body, etc. Request format:

    interface Request {
    body: string;
    headers: {[headerName: string]: string[]};
    method: string;
    path: string;
    queryParameters: {[paramName: string]: string[]};
    }

At the beginning of each script, Script Master automatically includes all necessary imports and special global objects, such as "request" for web-trigger scripts. This means you don't need to include them yourself; you can simply start writing your script.

// These components are added automatically by Script Master
import api, { authorize, fetch, route } from '@forge/api';
const request = '...request details...';

// Your script starts here:

your script

Logging and debugging​

note

Something is missing or not clear? Contact our Support team