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

humane-indexer

v2.0.3

Published

Indexer module for Humane Discovery

Downloads

21

Readme

humane-indexer

APIs

Note:

  • Indexer APIs are available at: http://<server-url>/:instanceName/indexer/api.
  • All types must be valid index types defined in configuration.
  • BODY must be valid JSON.
  • All requests shall have Content-Type header as: Content-Type: application/json

Add

This method adds document of given type.

Method 1
  • TYPE : POST

  • URL : /add

  • BODY : {type: <type>, doc: <data>}

  • SUCCESS RESPONSE :

    • Http Status Code: 200 or 201

    • Sample Response Body :

      {
        "_id": "18473",
        "_type": "abcType",
        "_index": "xyzIndex",
        "_version": 5,
        "_statusCode": 201,
        "_status": "SUCCESS",
        "_operation": "ADD",
        "serviceTimeTaken": "127.377"
      }
  • ERROR RESPONSES : See Common Error Scenarios

    • Case: Document already exists

      • Http Status Code: 404

      • Sample Response Body :

        {
          "_id": "18473",
          "_type": "abcType",
          "_index": "xyzIndex",
          "_statusCode": 404,
          "_status": "FAIL",
          "_failCode": "EXISTS_ALREADY",
          "_operation": "ADD",
          "serviceTimeTaken": "70.075"
        }
    • See Common Error Scenarios

Method 2
  • TYPE : PUT

  • URL : /:type

  • BODY : {doc: <data>}

  • SUCCESS RESPONSE : Same as method 1

  • ERROR RESPONSES : Same as method 1

Full Update

This method does full update of document of given type and id.

Method 1
  • TYPE : POST

  • URL : /update

  • BODY : {type: <type>, id: <id>, doc: <data>}

  • SUCCESS RESPONSE :

    • Http Status Code: 200

    • Sample Response Body :

      {
        "_id": "18473",
        "_type": "abcType",
        "_index": "xyzIndex",
        "_version": 1,
        "_statusCode": 200,
        "_status": "SUCCESS",
        "_operation": "UPDATE",
        "serviceTimeTaken": "255.350"
      }
  • ERROR RESPONSES :

    • Case: Not found ID

      • Http Status Code: 404

      • Sample Response Body :

        {
          "_id": "18473",
          "_type": "abcType",
          "_index": "xyzIndex",
          "_statusCode": 404,
          "_status": "FAIL",
          "_failCode": "NOT_FOUND",
          "_operation": "UPDATE",
          "serviceTimeTaken": "70.075"
        }
    • See Common Error Scenarios

Method 2
  • TYPE : POST

  • URL : /:type/:id

  • BODY : {doc: <data>}

  • SUCCESS RESPONSE : Same as method 1

  • ERROR RESPONSES : Same as method 1

Merge

This method merges given data with existing data of given type and id.

  • TYPE : POST

  • URL : /merge

  • BODY : {type: <type>, id: <id>, doc: <data>}

  • SUCCESS RESPONSE :

    • Http Status Code: 200

    • Sample Response Body :

      {
        "_id": "18473",
        "_type": "abcType",
        "_index": "xyzIndex",
        "_version": 1,
        "_statusCode": 200,
        "_status": "SUCCESS",
        "_operation": "PARTIAL_UPDATE",
        "serviceTimeTaken": "133.818"
      }
  • ERROR RESPONSES :

    • Case: Not found ID

      • Http Status Code: 404

      • Sample Response Body :

        {
          "_id": "18479",
          "_type": "abcType",
          "_index": "xyzIndex",
          "_statusCode": 404,
          "_status": "FAIL",
          "_failCode": "NOT_FOUND",
          "_operation": "MERGE",
          "serviceTimeTaken": "16.548"
        }
    • See Common Error Scenarios

Upsert

This method adds data of given type if it does not exist, else makes full update.

Method 1
  • TYPE : POST

  • URL : /upsert

  • BODY : {type: <type>, doc: <data>}

  • SUCCESS RESPONSE : For new document: add response, for existing document: update response

  • ERROR RESPONSES : See Common Error Scenarios

Method 2
  • TYPE : POST

  • URL : /:type

  • BODY : {doc: <data>}

  • SUCCESS RESPONSE : Same as method 1

  • ERROR RESPONSES : Same as method 1

Remove

This method removes document of given type and id.

Method 1
  • TYPE : POST

  • URL : /remove

  • BODY : {type: <type>, id: <id>}

  • SUCCESS RESPONSE :

    • Http Status Code: 200

    • Sample Response Body :

      {
        "_id": "18473",
        "_type": "abcType",
        "_index": "xyzIndex",
        "_version": 4,
        "found": true,
        "_statusCode": 200,
        "_status": "SUCCESS",
        "_operation": "REMOVE",
        "serviceTimeTaken": "122.236"
      }
  • ERROR RESPONSES :

    • Case: Not found ID

      • Http Status Code: 404

      • Sample Response Body :

        {
          "_id": "18473",
          "_type": "abcType",
          "_index": "xyzIndex",
          "_statusCode": 404,
          "_status": "FAIL",
          "_operation": "REMOVE",
          "_failCode": "NOT_FOUND",
          "serviceTimeTaken": "84.184"
        }
    • See Common Error Scenarios

Method 2
  • Type : DELETE

  • URL : /:type/:id

  • SUCCESS RESPONSE : Same as method 1

  • ERROR RESPONSES : Same as method 1

Common Error Scenarios

  • Case: Undefined Type - when type is not specified

    • Http Status Code: 400

    • Sample Response Body :

      {
        "_statusCode": 400,
        "_errorCode": "VALIDATION_ERROR",
        "_status": "ERROR",
        "details": {
          "code": "UNDEFINED_TYPE"
        },
        "_errorId": 1458790949474
      }
  • Case: Unrecognized Type - when type is not among the configured

    • Http Status Code: 400

    • Sample Response Body :

      {
        "_statusCode": 400,
        "_errorCode": "VALIDATION_ERROR",
        "_status": "ERROR",
        "details": {
          "code": "UNRECOGNIZED_TYPE",
          "type": "XYZ"
        },
        "_errorId": 1458790974877
      }
  • Case: Undefined ID - when ID is not specified or can not be calculated

    • Http Status Code: 400

    • Sample Response Body :

      {
        "_statusCode": 400,
        "_errorCode": "VALIDATION_ERROR",
        "_status": "ERROR",
        "details": {
          "code": "UNDEFINED_ID"
        },
        "_errorId": 1458748607506
      }
  • Case: Internal Service Error - when there is some internal service error

    • Http Status Code: 500

    • Sample Response Body :

      {
        "_statusCode": 500,
        "_errorCode": "INTERNAL_SERVICE_ERROR",
        "_status": "ERROR",
        "_errorId": 1458819775194
      }