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

webhdfs-proxy

v0.1.2

Published

WebHDFS REST API proxy

Downloads

15

Readme

webhdfs-proxy

Build Status NPM version

webhdfs-proxy is a naive proxy layer for Hadoop WebHDFS REST API, which can be used to mock WebHDFS API requests in the tests or help to replace/migrate existing HDFS data storage (migration to S3, GridFS or custom storage etc.).

Usage

Storage specific logic is implemented in storage middleware. webhdfs-proxy itself implements basic requests validation, parsing and redirects simulation, and utilities for handling WehbHDFS API requests and responses.

Supported WebHDFS REST API operations (Hadoop 2.4.x compatible) at the moment are:

  • APPEND
  • CREATE
  • CREATESYMLINK
  • DELETE
  • GETFILESTATUS
  • LISTSTATUS
  • MKDIRS
  • OPEN
  • RENAME
  • SETOWNER
  • SETPERMISSIONS

Install module:

npm install webhdfs-proxy --save

Basic middleware skeleton:

var WebHDFSProxy = require('webhdfs-proxy');

WebHDFSProxy.createServer({
  path: '/webhdfs/v1',
  validate: true,

  http: {
    port: 80
  },

  https: {
    port: 443,
    key: '/path/to/key',
    cert: '/path/to/cert'
  }
}, function storageHandler (err, path, operation, params, req, res, next) {
  // Pass error to WebHDFS REST API user
  if (err) {
    return next(err);
  }

  switch (operation) {
    case 'open':
      // Implement operation logic here
      return next();
      break;

    case 'create':
      // Implement operation logic here
      return next();
      break;
      
    case 'mkdirs':
      // Implement operation logic here
      return next(new Error('Internal error'));
      break;
  }
}, function onServerCreate (err, servers) {
  if (err) {
    console.log('WebHDFS proxy server was not created: ' + err.message);
    return;
  }

  // Proxy server was successfully created
});

For extended usage and implementing your own storage middleware, please see example middlewares.

Server options

  • path (optional, string, '/webhdfs/v1') - API endpoint path
  • validate (optional, boolean, 'true') - Enables requests validation. Supported schemas are loacated in schemas/ directory.
  • http (optional, object) - HTTP options. HTTP server is created always.
  • http.port (optional, number, 80) - HTTP listening port.
  • https (optional, object) - HTTPS options.
  • https.port (optional, number, 443) - HTTPS listening port. If set then it enables HTTPS server automatically.
  • https.key (optional, string) - User defined path to key file. If not set then key will be generated on runtime.
  • https.cert (optional, string) - User defined path to cert file. If not set then certificate will be generated on runtime.

Middleware parameters

  • err - It can be ignored or passed to the client. Is set if request validation failed or unexpected runtime error occurred.
  • path - WebHDFS resource path
  • operation - WebHDFS API operation name
  • params - Map of parsed query parameters
  • req - Internal request object
  • res - Internal response object
  • next - Function which should be called when the request is fulfilled. Returns an error response if first argument is a valid error object.

Tests

Running tests:

npm test

Middlewares

Licence

MIT