New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

hook.io-restful

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hook.io-restful

RESTful interface for hook's, provides a RESTful web server for surfaced hooks

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

hook.io-restful

A hook to surface chosen hooks to the rest of the world via a RESTful interface. Hooks choose to register and provide documentation details.

installation

installing npm (node package manager)

  curl http://npmjs.org/install.sh | sh

installing hook.io

  npm install hook.io

installing hook.io-RESTful

  npm install hook.io-restful

Hook.io-restful config.json settings

{
  port: 8080, // port to use for HTTP communications
  debug: true
}

UNDER CONSTRUCTION

This hook is very much under construction with many things changing, but wanted to get it up for feedback.

Hook.io Events Names

RESTfulReady Notify's RESTfulHook's that a RESTfulServer is available to serve requests.


/* helloWorldHook.js */

var RESTfulHook = require('../../lib/restful').RESTfulHook,
    util        = require('util');

var helloWorldHook = exports.helloWorldHook = function(options){
  var self = this;
  RESTfulHook.call(self, options);
  
  self.exports = {};
  self.exports._hello = self.hello;
  self.exports._hello.description = 'Returns Hello World! if no name is specified or Hello <Name>! if name is specified.';
  self.exports._hello.schema = {
    name: {
      required: false,
      validation: 'string',
      description: 'The name to return in place of World.',
    }
  };
  self.exports._hello.route = 'hello';

  self.exports.sayHello = self.sayHello;
  self.exports.sayHello.description = 'Returns Hello World! if no name is specified or Hello <Name>! if name is specified.';
  self.exports.sayHello.schema = {
    name: {
      required: false,
      validation: 'string',
      description: 'The name to return in place of World.',
    }
  };
  
  self.exports.sayHelloTo = self.sayHelloTo;
  self.exports.sayHelloTo.description = 'Returns Hello World! if no name is specified or Hello <Name>! if name is specified.';
  self.exports.sayHelloTo.schema = {
    name: {
      required: true,
      validation: /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/gi,
      description: 'The name to return in place of World.',
    }
  };
};

util.inherits(helloWorldHook, RESTfulHook);

helloWorldHook.prototype.hello = function(data, callback){
  if(!(data&&data.name)) callback(null, 'Hello world!');
  else callback(null, 'Hello '+data.name);
};

helloWorldHook.prototype.sayHello = function(data, callback){
  if(!(data&&data.name)) callback(null, 'Hello world!');
  else callback(null, 'Hello '+data.name);
};

helloWorldHook.prototype.sayHelloTo = function(data, callback){
  if(!(data&&data.name)) callback({error: 'No name specified'});
  else callback(null, 'Hello '+data.name);
};


/* helloWorld.js */
/* This is basically a way to instanciate the helloWorldHook without using .spawn */

#!/usr/bin/env node

var Helloworld = require('./helloWorldHook').helloWorldHook;
var myHook = new Helloworld();

myHook.start();

FAQs

Package last updated on 22 Feb 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts