npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gigya/destination

v1.0.0-beta.12

Published

Gigya API Client with SAP Cloud SDK Destination Support

Readme

@gigya/destination

Gigya API client with SAP Cloud SDK destination support using openapi-fetch middleware.

Installation

npm install @gigya/destination openapi-fetch @sap-cloud-sdk/connectivity @sap-cloud-sdk/http-client

Usage

Basic Usage

import { createGigyaDestination } from '@gigya/destination'

const client = createGigyaDestination({
  destination: 'GIGYA_DESTINATION'
})


// Type-safe API calls with SAP destination
const { data, error } = await client.GET('/accounts.getAccountInfo', {
  params: {
    query: { UID: 'user123' }
  }
})

if (error) {
  console.error(error)
} else {
  console.log(data)
}

With Custom Headers

const client = createGigyaDestination({
  destination: 'GIGYA_DESTINATION',
  headers: {
    'X-Custom-Header': 'value'
  }
})

With Destination Object

import { getDestination } from '@sap-cloud-sdk/connectivity'

const destination = await getDestination({
  destinationName: 'GIGYA_DESTINATION'
})

const client = createGigyaDestination({
  destination
})

Advanced Middleware

import { createClient, type Middleware } from 'openapi-fetch'
import type { paths } from '@gigya/destination/schema'

// Create client with custom middleware
const loggingMiddleware: Middleware = {
  async onRequest({ request }) {
    console.log('Request:', request.url)
    return request
  },
  async onResponse({ response }) {
    console.log('Response:', response.status)
    return response
  }
}

const client = createClient<paths>({
  baseUrl: 'https://accounts.gigya.com'
})

client.use(loggingMiddleware)

SAP BTP Destination Configuration

Create a destination in SAP BTP Cockpit:

Name=GIGYA_DESTINATION
Type=HTTP
URL=https://accounts.gigya.com
ProxyType=Internet
Authentication=BasicAuthentication
User=<your-api-key>
Password=<your-secret-key>

Type-Safe Requests

All requests are fully typed based on the OpenAPI schema:

// TypeScript knows exact parameters and response types
const { data, error } = await client.POST('/accounts.setAccountInfo', {
  params: {
    query: {
      UID: 'user123',
      profile: {
        firstName: 'John',
        lastName: 'Doe'
      }
    }
  }
})

if (data) {
  // data is typed based on the OpenAPI response schema
  console.log(data)
}

Error Handling

const { data, error } = await client.GET('/accounts.getAccountInfo', {
  params: { query: { UID: 'user123' } }
})

if (error) {
  // error is typed based on possible error responses
  console.error('Request failed:', error)
  return
}

// TypeScript knows data is defined here
console.log(data)

How It Works

This package uses openapi-fetch with custom middleware to:

  1. Intercept requests before they're sent
  2. Resolve SAP destination (with caching)
  3. Replace base URL with destination URL
  4. Add authentication headers from destination
  5. Execute request through SAP Cloud SDK

The middleware pattern from openapi-fetch provides:

  • ✅ Type-safe requests and responses
  • ✅ Zero runtime overhead
  • ✅ Full control over request/response
  • ✅ Easy to extend with custom middleware
  • ✅ Compatible with SAP Cloud SDK

Examples

Cloud Foundry App

import { createGigyaDestination } from '@gigya/destination'
import express from 'express'

const app = express()
const gigya = createGigyaDestination({
  destination: 'GIGYA_DESTINATION'
})

app.get('/account/:uid', async (req, res) => {
  const { data, error } = await gigya.GET('/accounts.getAccountInfo', {
    params: { query: { UID: req.params.uid } }
  })
  
  if (error) {
    return res.status(500).json({ error })
  }
  
  res.json(data)
})

app.listen(process.env.PORT || 3000)

With Additional Middleware

import { createGigyaDestination } from '@gigya/destination'
import type { Middleware } from 'openapi-fetch'

// Add custom middleware for request tracking
const trackingMiddleware: Middleware = {
  async onRequest({ request }) {
    request.headers.set('X-Request-ID', crypto.randomUUID())
    return request
  }
}

const client = createGigyaDestination({
  destination: 'GIGYA_DESTINATION'
})

// Add additional middleware
client.use(trackingMiddleware)

Documentation

License

MIT