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

oc-riak-storage-adapter

v0.4.0

Published

RiakCS storage adapter for OC

Downloads

16

Readme

RiakCS as registry storage

⚠️ THIS ADAPTER IS IN ACTIVE DEVELOPMENT, DON'T USE IN PRODUCTION

RiakCS is a S3 compliant object storage, based on the distributed database Riak by Basho. In case AWS S3 isn't an option RiakCS may be an alternative to run the storage in-house or locally as a developer.

Installing RiakCS locally

If you want to try it out locally, start with installing RiakCS using docker.

To run and start three buckets, do the following (check https://github.com/ianbytchek/docker-riak-cs for further info):

docker run --env 'RIAK_CS_BUCKETS=foo,bar,baz' --publish '8080:8080' --name 'riak-cs' ianbytchek/riak-cs

This will expose RiakCS on http://localhost:8080/. To be able to interact with the storage you need to get the access key and secret key. You will find this in the RiakCS log. To start with, find the containerid for the container that we named riak-cs:

docker ps

After RiakCS has started, which may take a minute or two, the keys will show up top of the log.

docker logs <containerid>

Starting a registry

Make sure you have installed the oc package and the Riak storage adapter.

npm install -g oc
npm install oc-riak-storage-adapter

Create an index.js file and add the access key and secret key to the snippet below.

'use strict';
const oc = require('oc');
const riak = require('oc-riak-storage-adapter');

let configuration = {
  verbosity: 5,
  baseUrl: 'http://localhost:3333',
  port: 3333,
  tempDir: './temp/',
  refreshInterval: 600,
  pollingInterval: 5,
  storage: {
    adapter: riak,
    options: {
      key: '<ACCESS KEY>',
      secret: '<SECRET KEY>',
      bucket: 'foo',
      region: 'us-east-1',
      componentsDir: 'components',
      signatureVersion: 'v2',       // Use v2 for RiakCS
      sslEnabled: false,
      path: 'http://localhost:8080/foo/',
      s3ForcePathStyle: true,       // Necessary to get the path right
      debug: true,                  // Log what AWS is up to to stdout
      // Override endpoint, this is passed straight to AWS.Endpoint constructor - https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Endpoint.html
      endpoint: 'http://localhost:8080'
    }
  },
  env: { name: 'production' }
};

let registry = new oc.Registry(configuration);

registry.start(function(err, app){
  if(err) {
    console.log('Registry not started: ', err);
    process.exit(1);
  }
});

Now start the registry:

node index.js

The registry should be now be exposed on http://localhost:3333/.

Publish a component

Go to the directory that contains the component you want to publish. First you have to add the registry by doing:

oc registry add http://localhost:3333/

Finally, to publish the component to the registry run

oc publish my-component/

Now the component should be available at http://localhost:3333/my-component.

Configuring endpoint

In the example above the full URL is used to specify the storage endpoint, ie http://localhost:8080. If the protocol is omitted, localhost:8080, the configuration will fallback to https.

Troubleshooting

If you run into trouble when accessing RiakCS the s3cmd can be a helpful companion. Install using pip, homebrew any other appropriate tool. See also https://github.com/s3tools/s3cmd/blob/master/INSTALL.

Create a file named s3.cfg and add the following snippet with your own access key and secret key:

[default]
access_key = <ACCESS KEY>
host_base = localhost:8080
host_bucket = foo
secret_key = <SECRET KEY>
signature_v2 = True

For example to list objects

s3cmd -c s3.cfg --no-ssl setacl --acl-public s3://foo/storage/components-details.json

License

MIT