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

remote-smplcnf

v1.0.0

Published

Promised JSON config reader with support for S3 and http.

Downloads

5

Readme

remote-smplcnf

Build Status

Promised JSON config reader with support for loading configurations from remote (http and aws s3).

This module is a simple wrapper around smplcnf, adding a http_load(url) function.

How to use it

See smplcnf for non-http usage.

Example:

const simple_config = require('remote-smplcnf');
const config = simple_config();

config.load('local-defaults.conf');
config.remote_load('http://example.org/mybucket/myconfig.json');
config.remote_load('s3://bucket/theconfig.json');

config('my_config_key', 'default_value')
.then(value => {
	// Yay!
});

The .remote_load(url) function

If the url has the format "s3://<bucket>/<key>", the AWS-SDK will be used for fetching the configuration.

Otherwise, axios will be used for making an HTTP GET request to the URL. If used in a web browser, the url can be relative.

AWS S3 credentials

Alternative 1: Running on Amazon EC2

If your IAM roles are properly set up, your EC2 instance will have access to the S3 bucket out of the box! (No hassle with credentials, etc.)

Alternative 2: ~/.aws/credentials

You can store your AWS credentials in ~/.aws/credentials in this format:

[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY

Alternative 3: Provide credentials as environment variables:

Use those environment variables to set your credentials:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Alternative 4: Make your bucket public

There are probably situations when you don't want this.

Tests

Unit tests and integration tests are in the same file. Unit tests are prefixed (or wrapped) with "Unit:" and integrations tests are prefixeda (or wrapped) with "Integration:" in the description().

Unit tests

Run the unit tests:

npm test

Integration tests

Requires docker-compose version 1.10.0 or later, and docker (only tested with docker version 1.12.1).

Run the interation tests:

npm run integrationtests

AWS credentials for integration tests

Pass your AWS credentials to the integration tests containers using environment variables:

AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=XXX npm run integrationtests