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

wsh

v0.1.4

Published

The easiest way to work with APIs: Integrate APIs in minutes, better performance, easy authentications

Downloads

14

Readme

Webshell node.js SDK

The easiest way to use Webshell in javascript using Node.js

I - Create an app on webshell

To use Webshell, you have to create an app in your Dashboard which will generate valid API Keys.

II - Setup webshell.js

The easier way to install this sdk is to use npm:

npm install wsh

You can also clone this repo or download the latest release, to add it into your node_modules folder.

III - Hello world app

This is a simple app using Webshell. To run this sample, you have to replace MY_WEBSHELL_PUBLIC_KEY, MY_WEBSHELL_SECRET_KEY, MY_DOMAIN with valid infos from the registered app.

wsh = require('wsh');

// init webshell with authentications keys
wsh.init({
  key:"MY_WEBSHELL_PUBLIC_KEY",
	secret:"MY_WEBSHELL_SECRET_KEY",
	domain:"MY_DOMAIN" // e.g: mysite.com
});

// set events
wsh.on('error', function(err) {
	console.log('wsh error:', err);
});
wsh.on('process', function(data, meta) {
	console.log('processing', {
		'data': data,
		'meta': meta
	});
});
wsh.on('success', function(res) {
	console.log('succeeded, result:', res);
});

// execute webshell code
wsh.exec({
	code: function() {
		for (var i in args.myarr)
			echo(args.myarr[i]);
		dump(args);
		return apis.tumblr.getPosts({"base-hostname": "webshellnews.tumblr.com"}, {view:null});
	},
	args: {myarr: ["hello", "world"]}
});

Pretty simple hm ?! You can call any other APIs on the platform in the same way. The javascript given in the code attribute of wsh.exec() is processed on our server and we retrieve all kind of data for you.

SDK Reference

wsh.init({key, secret, csid, domain})

All these parameters must be strings and are optional. After initializing your wsh object with the wsh.init, you can use wsh.exec with these default parameters.

wsh.exec({...}) or wsh.exec(code)

This method executes some code on webshell. The only required parameter (if you have init wsh before) is code. This can be directly the first argument, or a key of the given object. The object can take these parameters:

wsh.exec({
  code: function() {
    // some code which have be executed by Webshell
  },
  args: ... // data to use in the script
  here: {latitude, longitude} // only if you wish to manage geolocation of your users
  
  csid: "..."      //   You can manage a webshell session by its key
  session: {}      //   or any storing object

  key: "..."       //   These parameters are authentications informations
  secret: "..."    //   and only required if you did not set them with wsh.exec
  domain: "..."    //
})

code can be a string of the javascript, or a function with the javascript which need to be executed by Webshell.

Events

The wsh object can send several events:

wsh.on('process', ...)

When the sdk receive a view from the server.

wsh.on('success', ...)

When an execution finishes and returns a result.

wsh.on('error', ...)

When any error on webshell or sdk occurs.

About webshell scripts

You can try online your Webshell code in the API Editor and include your script using the fs object inside your webshell code (see builtins/fs())

Read more information about Webshell in the documentation