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

chiliconnector

v1.0.3

Published

Wrapper for dealing with CHILI publish web services

Downloads

28

Readme

ChiliConnector

A small library that allows you to easily make web service calls to your CHILI publisher install. To learn more about CHILI publisher check out chili-publish.com

This module was developed for servers running CHILI Publisher >5.6

This will work with older CHILI installs, but you must use in SOAP mode and some functions will be missing. Support for older CHILI versions may be added in the future.

Installation

npm install chiliconnector

Usage

First

Frist, you need to add the script as requirement for your code.

Second

Second, you need to initilize a new ChiliConnector class. This class takes two parameters:

  • The beginning URL of the endpoit
  • Any options (not required)

It should be noted that at the current version, the URL requirement does not intelligently protect from putting in the wrong endpoint address - in the future this will change.

So if you REST endpoit is: http://www.crowe.chili/chili/rest-api/v1/system/apikey?environmentNameOrURL=Admin

Then you want to use only up until the "rest-api" point. So the URL you would use as a paramter is: http://www.crowe.chili/chili/

Third

Use the functions to make request to the server. The last paramtere of all request will be a boolean to determine whether you get a JSON or XML response back.

I strongly suggest using a try catch block as it is required by Node but also because you will get your server errors from the error message.

Fourth

Wait for your response using the two most come ways to deal with promises: "await" or promise syntax (see example below).

Fifth

You will get a JSON or XML response back depending on the parameter set in the third step.


Using Await

const ChiliConnector = require('chiliconnector').ChiliConnector;

let connector = new ChiliConnector("http://www.crowe.chili/chili/");

async function main() {
    try {
        let apiKey = (await connector.generateApiKeyAsync("admin", "admin", "admin")).key;

        console.log(apiKey);
    }
    catch (error)
    {
        console.log(error);
    }
}

main();

//Output should be an apiKey or an error if you had the wrong info

Using Promises

const ChiliConnector = require('chiliconnector').ChiliConnector;

let connector = new ChiliConnector("http://www.crowe.chili/chili/");

function main() {
	connector.generateApiKeyAsync("admin", "admin", "admin"))
		.then(res => 
		{
			console.log(res.key);
		})
		.catch(err)
		{
			console.log(err);
		}
}
main();

//Output should be an apiKey or an error if you had the wrong info

Options

When you create a ChiliConnector class, you can provide two parameters the URL of the beginning your endpoint and some options.

The options are simple an Object, and you can include or exclude the following options. Below is the following default options:

    	{
        			url: url, // this is set by the constructor, but you can change the URL path
        			version: 1, // Version of the URL
        			rest: true, // Set to 'true' to use REST or 'false' to use SOAP
        			autoCDATA : true // Set to 'true' will add CDATA tags around any XML paramater
    	}`

So for example, if you want to create a ChiliConnector that uses SOAP, you would just add the option during initilization.

const ChiliConnector = require('./main').ChiliConnector;

let connectorSoap = new ChiliConnector("http://www.crowe.chili/5.6/",
    {
        rest: false
    });

Browser Usage

There are many ways to build this package to work with a browser, but personally I use Parcel because it is super easy.

Please see Parcel's website for deeper documentation and installation instructions, but the most simple use case is you write your code in say a file (or files), and use Parcel to combine everything into one package which you will load in the browser.

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style.