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

nedoto-client

v1.0.8

Published

Nedoto Typescript HTTP Client provide access to the Nedoto HTTP APIs

Downloads

19

Readme

Nedoto Typescript Client

MIT Licensed ci

Official Typescript package to connect to Nedoto API.

References:

  • Nedoto website: https://nedoto.com
  • Nedoto app website: https://app.nedoto.com
  • Nedoto documentation website: https://docs.nedoto.com

Installation

Installation with npm:

npm install nedoto-client

Usage

To retrieve your configuration from Nedoto API you should create a new instance of the NedotoClient and then use the Client to retrieve your configuration with the unique configuration slug configured in Nedoto.

The response object is of type Response and with it, you can retrieve the Configuration object.

From the configuration object you can access your configuration value calling the getValue() method.

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  const configuration = response.getConfiguration();
  console.log(configuration.getValue()); // will print the value of the Configuration saved in https://app.nedoto.com/configurations
}).catch ((error) => {
  console.error(error);
})

The Nedoto Response

After calling the get() method with the Nedoto client, you'll receive a Response object.

Understand if everything is ok

To understand if everything went fine after retrieving your configuration, you should use the getStatus() method.

It will return a standard HTTP status.

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  console.log(response.getStatus()); // ex. 200 HTTP status code
}).catch ((error) => {
    console.error(error);
});

Alternatively you could you use the failed() method that will inform you if there was a failure by returning a boolean value if the HTTP status code is different from 200 (HTTP OK).

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  console.log(response.failed()); // ex. true if HTTP status is different from 200
}).catch ((error) => {
    console.error(error);
});

Understand the errors

After checking if the status of the Response you may want to understand which errors happened during the API request.

For this you could use the getErrors() method.

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  console.log(response.getErrors());
}).catch ((error) => {
    console.error(error);
});

the getErrors() method will return an array of reasons explaining why:

[
  'Error message 1',
  'Error message 2',
  'Error message 3',
  // ...
];

Retrieve the Configuration

To retrieve your configuration value you must use the getConfiguration() method.

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  const configuration = response.getConfiguration();
  console.log(configuration.getValue()); // will print the value of the Configuration saved in https://app.nedoto.com/configurations
}).catch ((error) => {
    console.error(error);
});

Understand the configuration type

When you define a configuration in Nedoto you must define the type of your configuration.

To retrieve the configuration type you should use the getType() method.

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  const configuration = response.getConfiguration();
  console.log(configuration.getType()); // this will print the type of the configuration saved in https://app.nedoto.com/configurations, ex. 'string', 'int', 'json', etc.
}).catch ((error) => {
    console.error(error);
});

Access the creation date?

By using the getCreatedAt() you can access the creation Date of the configuration.

import NedotoClient from 'nedoto-client';

const nedotoClient = new NedotoClient('your-api-key');

nedotoClient.get('your-slug').then((response) => {
  const configuration = response.getConfiguration();
  console.log(configuration.getCreatedAt()); // ex. 2024-02-12T16:09:21+00:00
}).catch ((error) => {
    console.error(error);
});

Want to improve something?

Please feel free to open a PR if you want to improve something on this package.