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

cloudmine-servercode

v1.2.1

Published

A Way to run Node.js apps on CloudMine's Logic Engine

Downloads

4

Readme

Node Code-Runner

This package provides the raw interface for CloudMine's Javascript Server Snippets.

Unless you are looking to modify this directly and submit a pull request, you are most likely looking for our local CLI testing tool.

Usage

Install the package as a dependency

npm install cloudmine-servercode --save

Once installed, you can write your code normally. With this library, you can install any module you want, as long as it's in your package.json file.

Once your snippets are written, you will have to start to the CloudMine code-runner. The code-runner automatically fields requests to your code, and will call the appropriate snippet.

To start the coderunner, do:


var CloudMineNode = require('cloudmine-servercode');

CloudMineNode.start(module, './index.js', function(err) {
  console.log('Server Started?', err);
});

.start takes two parameters:

  1. The current module
  2. A path to a file, and expects to get a Node.js file that has exported modules in the form of an object. Each module key will be used as the name of the snippet (and is required), and the value should be of the form: function(req, reply).

Reply is the method completion handler. You should call reply(anything) to finish the method and return anything.

Example

To see this fully in action, we have a snippet base setup here. You can fork or clone the example and see how it works. Right out of the box you can deploy it to CloudMine and run the snippet.

Technical Details

When you call .start, the CloudMine Code Runner is creating an HTTP server that will handle requests for your application automatically. This server is started on port 4545, so you should not use that port.

When you execute the snippet from CloudMine, the HTTP request is forwarded to your snippet. We use Hapi to handle the request. Rather than pass in a subset of functionality, we send your snippet the entire Request object (docs). The reply interface is also the same, (docs), which means anything you can pass back to Hapi you can pass back here.

Upgrading

Each version of cloudmine-node will lockdown the version of Hapi, so you can be sure the interface won't change underneath you. However, Hapi moves very quickly, and future versions may break your application, so upgrade carefully. This project follows Semantic Versioning, so upgrades to Hapi that are not back backwards compatible will also result in a major version incrementing.