New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bearer/functions

Package Overview
Dependencies
Maintainers
4
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bearer/functions

Bearer Functions

0.100.1-next.48
Source
npm
Version published
Maintainers
4
Created
Source

@bearer/functions

Usage

Creating a FetchData function

import { FetchData, TOAUTH2AuthContext } from '@bearer/functions'
import Client from './client'

export default class ListPullRequestsFunction {
  static functionName: string = 'listPullRequests'
  static functionType: any = FetchData

  static async action({ context, params }: { context: TOAUTH2AuthContext; params: any }) {
    try {
      const { data } = await Client(context.authAccess.accessToken).get(`/repos/${params.fullName}/pulls`, {
        params: { per_page: 10, ...params }
      })
      return { data }
    } catch (error) {
      return { error: error.toString() }
    }
  }
}

Creating a SaveData function

import { SaveState, TOAUTH2AuthContext } from '@bearer/functions'
import Client from './client'

export type TState = {
  pullRequests: any
}

export type TParams = {
  fullName: string,
  page?: number
}

export default class ListPullRequestsFunction {
  static functionName: string = 'listPullRequests'
  static functionType: any = SaveState

  static async action({ context, params, state }: { context: TOAUTH2AuthContext; params: TParams, state: TState }) {
    try {
      const { data } = await Client(context.authAccess.accessToken).get(`/repos/${params.fullName}/pulls`, {
        params: { per_page: 10, ...params }
      })
      return { data, state: { pullRequests: data } }
    } catch (error) {
      return { error: error.toString() }
    }
  }
}

FAQs

Package last updated on 07 Mar 2019

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