Neutered Paranoid Meerkat
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

higgytools

1.5.11 • Public • Published

higgytools

A collection of node simplifications for web serving and requesting (along with some system commands implemented).

NOTE: If you use C#, check out https://github.com/haydenhigg/Vitesse for the fully-developed version of this package, and a nodejs version of Vitesse is coming soon.

To quickly test the package after installation, type this command from your package directory: node node_modules/higgytools/test.js

utility

Miscellaneous helper functions

parse URL parameters to JSON by providing the result of url.parse(path)

parseParameters(urlObject)

requests

Simplified GET and POST requests

GET

get(url, callback)

There's an optional third argument to specify whether you want the response encoding type to be set to binary (for pictures).

POST

post(url, body, callback)

There's an optional fourth argument to specify the response type (default is 'application/json')

serving

Each of these returns a server. A simple HTTP server, a server to serve one file quickly, a powerful static file server, or a server with directl control over the responses with routes.

serve

serve(callback)

serve a file

serveFile(filePath)

serve all static files

serveStatic()

The optional first argument is routes, which will serve as an override to the static response. See the serveRoutes function for more detail on routes. You can specify how many folders deep to start the file search by setting the module's parentDirectories property (default is 0). You can specify an anchor file by setting the module's anchor property.

dynamically serve manually specified routes

serveRoutes(routes)

Routes is an object of

{route: function(request) {
    return {body: body, options: options};
}}

or

{route: function(request, response)}

where route is a string path, request is a URL object, the body of the return object is the body of the response, and the options are the options to write to the head of the response.

system commands

If you have these tools installed this can provide just a simple node interface with them.

arp

arp(callback)

Can specify command options (default is none, but command is often used with '-a')

nmap

nmap(ip, callback)

Can specify command options (default is none)

listIPs

listIPs(min, max)

Manually tries to find a hostname for every ip from xxx.xxx.xx.min to xxx.xxx.xx.max. The beginning is found from the router's IP address.

to-do:

finish implementing socket servers

install

npm i higgytools

Downloadsweekly downloads

4

version

1.5.11

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability