You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@google-cloud/synthetics-sdk-api

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/synthetics-sdk-api

NodeJS distribution of the API Specification that must be complied with for integrating with Google Cloud Monitoring Synthetics

0.7.0
latest
Source
npmnpm
Version published
Weekly downloads
1.7K
15.72%
Maintainers
2
Weekly downloads
 
Created
Source

npm version

Synthetics SDK API

Note: This is an experimental package under active development. New releases may include breaking changes.

Installation

npm install --save @google-cloud/synthetics-sdk-api

Usage With Cloud Function V2

Google Cloud Monitoring Synthetics requires a Cloud Function v2 target, and as such, this guide explains how to set up a simple function that uses the @google-cloud/synthetics-sdk-api package.

$ npm init
$ npm install --save @google-cloud/synthetics-sdk-api
$ npm install --save @google-cloud/functions-framework

# This example uses node-fetch for http requests
$ npm install --save node-fetch

Usage With runSyntheticHandler Middleware

This package provides an easy to use express compatible middleware for writing code that is invoked by Google Cloud Monitoring Synthetics. When a user written function is provided to it, a response is sent that may be consumed by Google's services. The following is an example index.js file that can be used as the entrypoint for a cloud function.

// index.js
const assert = require("node:assert");
const functions = require('@google-cloud/functions-framework');
const fetch = require("node-fetch");
const GcmSynthetics = require('@google-cloud/synthetics-sdk-api');

functions.http('SyntheticFunction', GcmSynthetics.runSyntheticHandler(async () => {
  const url = 'https://www.google.com/'; // URL to send the request to
  return await assert.doesNotReject(fetch(url));
}));

Usage Without Framework

As long as a Google Cloud Function exposes an http endpoint that complies with the API spec as defined in the Synthetics SDK API package, the Cloud Function will work as a target for a Synthetic Monitor. As such, this package includes a proto definition that contains the api spec, as well as typescript types that are generated from that proto.

This is predominantly important if you want to run a programmatic workflow for which other SyntheticSDKs are not a good fit, or if you want to use another language for your Google Cloud function for which there is no direct support.

const functions = require('@google-cloud/functions-framework');
const { SyntheticResult, GenericResultV1 } = require('@google-cloud/synthetics-sdk-api');

FAQs

Package last updated on 10 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts