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

hive-io-rest-example

v2.1.3

Published

An example REST module to help describe implementation details when leveraging the Hive^io framework.

Downloads

28

Readme

hive-io-rest-example

NPM Version License Code Coverage JavaScript Style Guide

An example REST module to help describe implementation details when leveraging the Hiveio framework.

Contents

Overview

This example contains a single resource to handle CRUD functionality of a generic Content object in a Restful implementation. It is a contrived but fairly robust example to illustrate different ways to use Actors in the Hiveio framework.

Endpoints

Once you get the app running using the setup instructions below, you can use the application from the following endpoint(s):

  • http://localhost/contents (GET, POST)
  • http://localhost/contents/<id> (GET, PATCH, DELETE)

NOTE: Network data models follow the Flux Standard Action specification for network transport. type and payload are derived from the routes and data sent respectively in this example.

Source Code

Getting Started

This is a straight forward CRUD example of a Content Entity that contains text, a couple Boolean flags, and a count of how many views it has. It stores these Contents in MongoDB. It leverages Hiveio's built-in telemetry solution with OpenTelemetry. Here's how to use it.

NOTE: This does not include robust error handling, authentication, and other strategies to keep the example straight forward.

Prerequisites

To use, you'll need:

Installing

To start using:

  1. Create the following files:
    • Dockerfile
      FROM fnalabs/hive-base-js:latest
      RUN npm install --production --no-optional hive-io-rest-example
    • docker-compose.yml
      version: '3.5'
      services:
        hive-base-js:
          build: .
          image: hive-base-js:production
          container_name: hive-base-js
          environment:
            ACTOR: ContentActor
            ACTOR_LIB: hive-io-rest-example
            ACTOR_URLS: "/contents,/contents/:id"
            CLUSTER_SIZE: 1
            HTTP_VERSION: 1
            SECURE: "false"
            TELEMETRY: "true"
            TELEMETRY_PLUGINS: '{"mongodb":{"enabled":true,"path":"@opentelemetry/plugin-mongodb"},"mongoose":{"enabled":true,"path":"@wdalmut/opentelemetry-plugin-mongoose"}}'
            TELEMETRY_SERVICE_NAME: content
            TELEMETRY_URL_METRICS: "http://collector:55681/v1/metrics"
            TELEMETRY_URL_TRACES: "http://collector:55681/v1/trace"
            MONGO_URL: "mongodb://mongo:27017/contents"
          depends_on:
            - collector
            - mongo
          ports:
            - 80:3000
          networks:
            - hive-io
        mongo:
          image: mongo:4.4.3
          container_name: mongo
          networks:
            - hive-io
          restart: on-failure
      
        # telemetry
        # TODO: you will need to define your own config for this example
        #       https://github.com/fnalabs/hive-io/blob/master/dev/collector/collector-config.yml
        collector:
          image: otel/opentelemetry-collector:0.18.0
          container_name: collector
          command: ["--config=/conf/collector-config.yml", "--log-level=ERROR"]
          depends_on:
            - zipkin
          volumes:
            - ./collector-config.yml:/conf/collector-config.yml
          networks:
            - hive-io
          restart: on-failure
        zipkin:
          image: openzipkin/zipkin:2.23.2
          container_name: zipkin
          ports:
            - 9411:9411
          networks:
            - hive-io
          restart: on-failure
      
      # networking
      networks:
        hive-io:
          driver: bridge
  2. Run the following commands:
    docker-compose up

Environment Variables

The table below contains a reference to the custom environment variables used in the example. Standard environment variables are documented for the following microservice containers:

Name | Type | Default | Description ---------- | ------- | --------------------------------- | ----------------------------------- MONGO_URL | String | 'mongodb://mongo:27017/contents' | url to connect to MongoDB instance