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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sr-sdks/api-sdk-axios

v1.26.0-pre.1

Published

OpenAPI client for @sr-sdks/api-sdk-axios

Downloads

632

Readme

@sr-sdks/[email protected]

This is a TypeScript/JavaScript client that utilizes axios.

It is generated from OpenAPI (Swagger) specs produced by the backend project.

It includes API classes and model interfaces compatible with the backend. The benefit of this is that the client side doesn't need to maintain matching interfaces or hand coded APIs.

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference)

Consuming

Navigate to the folder of your consuming project and run the following command to install from the published package:

npm install @sr-sdks/[email protected] --save

APIs available

The following APIs are available:

Example usage

You can use the SDK to make API calls to the server. For example, to get a list of users, you can use the following code:

Pre-requisites

  • An axios instance. This could simply be created with axios.create() or something more complex with interceptors for adding request Authorization headers, caching, response handling, etc. depending on application requirements.
  • Define a function which will prepare an instance of the API class to be used:
import { Configuration, UsersApi } from '@sr-sdks/api-sdk-axios';
import axiosInstance from './utils/axiosInstance';

// function for creating an instance of the UsersApi class
const GetUsersApi = () => {
  return new UsersApi(
    new Configuration(),
    process.env.REACT_APP_PERMISSIONS_API_BASE,
    axiosInstance,
  );
};

Example 1: Get a list of users for a workspace

Use the UsersApi class to make a call to the find all users endpoint.

import { User, UsersApi } from '@sr-sdks/api-sdk-axios';

// get the workspace id from somewhere, e.g.:
const workspaceId = 'workspace-id-from-path-params';
let users: User[];

try {
  const result = await GetUsersApi().usersControllerFindAllV2(workspaceId);

  users = result.data.items;
} catch (error) {
  // handle error
}

Example 2: Get the current user

Use the UsersApi class to make a call to the find user me endpoint.

import { User, UsersApi } from '@sr-sdks/api-sdk-axios';

let userMe: User;

try {
  const result = await GetUsersApi().usersControllerFindMe();

  userMe = result.data;
} catch (error) {
  // handle error
}

Example 3: Create an invitation

Use the InvitationApi class to make a call to the create invitation endpoint.

import { Configuration, CreateInvitationDto, Invitation, InvitationsApi } from '@sr-sdks/api-sdk-axios';

// function for creating an instance of the InvitationsApi class
const GetInvitationsApi = () => {
  return new InvitationsApi(
    new Configuration(),
    process.env.REACT_APP_PERMISSIONS_API_BASE,
    axiosInstance,
  );
};

let invitation: Invitation;
const createInvitationDto: CreateInvitationDto = {
  // properties of the invitation assembled from user-entered form data or CSV, etc.
};

try {
  const result = await GetInvitationsApi().invitationControllerCreate(createInvitationDto);

  invitation = result.data;
} catch (error) {
  // handle error
}

Generating

Use the scripts defined in the backend project.

Building

To build and compile the typescript sources to javascript use:

npm install
npm run build

Publishing

Commit and push the code. Bitbucket Pipelines will automatically publish the package.