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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pxys-request-occ

v1.0.6

Published

A simple framework to sign requests and send them to the OCC proxy

Readme

pxysService

Build Status

pxysService is a minimal utility to test, sign request and send them through to the proxy. Also can help you to parse proxy responses to show results to the client (front-end) with the errorManager.

Requirements

  • Access to proxy server you want to test
  • App Key & Secret Key for your proxy user
  • A machine with nodejs

Before start

It is highly recommended that you install cross-env utility globaly as it will help you later to set npm commands with personalized configs. From your cmd or bash use:

npm install -g cross-env

Setup

Create an object that will help you with your configuration like this:

{
  "host": "http://localhost:8080/",
  "timeout": 1000000,
  "appKey": "######",
  "secretKey": "$$$$$"
}

*Some test configs are provided by default on the ./config folder.

What values do I need to put?

  • host: The url for your proxy server, environment dependent
  • timeout: Maximum time before providing a timeout in ms
  • appKey: Credential given by your administrator
  • secretKey: Credential password given by your administrator Depending on the resources required you might need more or less time on the timeout key and different appKey & secretKey.

So now I want to start testing the project

To run with default config:

node ./server/index.js

Or if you have cross-env installed

npm run dev

Example:

url service:

The following code should provide an entry point to the url seus service:

// Document on: ./routes/testUrl
const { Router } = require('express');
const config = require('config');
const proxyConfig = config.get('proxy');
const PxysService = new require('../../services/pxysService');
const errorService = require('../../services/pxysErrorManager');

const router = new Router();
router.route('/testUrl').get((req, res) => {
  const reqObj = {};
  reqObj.service = 'seus';
  reqObj.version = 'v1_0';
  reqObj.method = 'post';
  reqObj.resource = 'seo';
  reqObj.instance = 'url';
  reqObj.parameters = '';

  const pxysService = new PxysService(proxyConfig);
  pxysService.pxysService((error, resPxys) => {
    if (error) {
      try {
        res.send(error);
        return;
      } catch (ex) {
        res.send(ex);
        return;
      }
    }
    res.send(resPxys);
  }, reqObj);
});

module.exports = router;

Then add it to ./server/index.js

const testUrl = require('./routes/testUrl');
...
server.use('/v1', [testUrl]);

Start your project with npm run dev Then in postman (GET) or browser perform the request to http://localhost:3000/v1/testUrl You should see the following output:

{
    "urls": [
        {
            "key": "",
            "url": "empleos/",
            "solr_url": "q=*:*",
            "redirect": false,
            "filters": null,
            "safe": false
        }
    ],
    "meta": {
        "time": 0.0646,
        "host": "dev-solr-01",
        "ip": "10.10.30.85 172.17.0.1 ",
        "version": "1.0.0"
    }
}

And in the console you should see:

### Ready on http://localhost:3000, NODE_ENV=development
::1 - - [04/Apr/2019:23:36:02 +0000] "GET /v1/testUrl HTTP/1.1" 200 195 "-" "PostmanRuntime/7.6.0"

Exception handling

When you perform a request there is a chance that you get an exception, this can be caused by some of the following:

  • Bad request
  • Service you are looking is down
  • Timeout with proxy or with service required
  • Proxy is down
  • Your computer cannot reach proxy
  • Error within your code

To handle this errors we provide an errorManager that can be imported from the library:

pxysService.pxysService((error, resPxys) => {
    if (error === null) {
        res.send({ resPxys, status: 200 });
    }
    try {
        // Bad request or similar
        // This will parse the errors from atreel
        const responseError = errorService.getErrorDescriptionFromErrorArray(error);
        console.log(`#### pxysService :: Error Description: ${JSON.stringify(responseError)} ####`);
        const response = { error: 'Ocurrió un error, intente más tarde.', status: 501 };
        res.send(response);
    } catch (ex) {
        // Internal error
        // This will handle timeouts and 404 nginx responses...
        console.log(`#### pxysService :: Error While parsing response #### ${JSON.stringify(ex)}`);
        const response = { error: 'Ocurrió un error, intente más tarde.', status: 500 };
        res.send(response);
    }
  }, reqObj);