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

@uniqoders/sdk

v1.0.0

Published

Front API:JSON Parser and Deserializer SDK

Downloads

115

Readme

Uniqoders API SDK

The Uniqoders API SDK is a TypeScript-based library designed to enhance the interaction with your API. Offering structured, type-safe requests and responses, this SDK streamlines the process of communicating with the backend.

Features

  • Axios for HTTP Requests: Utilizes Axios for robust and efficient HTTP request management.
  • TypeScript Integration: Leverages TypeScript for type-safe interactions, reducing runtime errors.
  • JSON to TypeScript Object Mapping: Automatically maps JSON responses from the API to TypeScript objects.
  • Cancellable Requests: Supports cancelling of ongoing HTTP requests.
  • Customizable Configuration: Designed for easy and flexible configuration to fit various API interaction requirements.
  • Deserialization: Automatically maps JSON responses from JSON:API snake_case to camelCase without attributes, includes and relations

Installation

Install the SDK into your project using one of the following package managers:

Using Yarn

yarn add uniqoders-sdk

Using NPM or PNPM

npm install uniqoders-sdk

Usage

Initialization

Create an instance of ApiClient to start interacting with the API:

import ApiClient from '@uniqoders/sdk';

const API_URL = "https://api.example.com";
const HEADERS = {'Accept-Language': 'en'};

const apiClient = new ApiClient(API_URL, HEADERS);

Making API Requests

Use the ApiClient to perform API requests:

// Example of a GET request
apiClient.request({
    method: 'GET',
    url: '/users',
}).then(response => {
    console.log(response.data);
});

Response Handling

The responses are automatically parsed into the appropriate TypeScript objects:

apiClient.request({method: 'GET', url: '/user/1'})
    .then(response => {
        // Assuming response is a User object
        console.log(response.data.name);
    });

Advanced Features

Cancellable Requests

For scenarios such as rapid search where requests need to be cancelled:

apiClient.request({
    method: 'GET',
    url: '/search',
    params: {query: 'example'},
    options: {cancellable: true, cancelKey: 'searchRequest'}
});

Custom Object Mapping

You can define custom mappings for your TypeScript models:

class User extends BaseObject {
    // User model definition
}

// Set custom object mappings
apiClient.setObjects({
    user: attrs => new User(attrs)
});

How to Work

The library includes various npm scripts to facilitate development and build processes. These scripts can be executed using pnpm, npm, or yarn, based on your preference.

Available Scripts

  • "_clear": Cleans the build directories by removing all files in build/compiled and dist. Uses rimraf for safe and effective deletion across different platforms.

    pnpm run _clear
  • "_tsc": Compiles the TypeScript files of the project using the TypeScript compiler (tsc). This produces JavaScript files ready to be bundled and deployed.

    pnpm run _tsc
  • "_make-bundle": Bundles the project using rollup with the configuration defined in the Rollup config file.

    pnpm run _make-bundle
  • "build": Runs a series of scripts in sequence to clean, compile, and bundle the library. This script is a combination of the previous scripts, ideal for preparing the project for production.

    pnpm run build
  • "lint": Executes eslint to identify and report on patterns found in ECMAScript/JavaScript code, helping to maintain code quality and consistency.

    pnpm run lint
  • "lint:write": Similar to lint, but also attempts to fix automatically fixable issues in the code.

    pnpm run lint:write

These scripts enhance the development experience by streamlining tasks like cleaning build directories, compiling TypeScript files, bundling the final output, and maintaining code quality with linting.