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

archappenv

v1.0.16

Published

Provides Application Environment Variables from *.appenv.js / .env and Utilities

Downloads

3,127

Readme

archappenv · CircleCI GitHub license npm version Build Status Coverage Status

Provides Application Environment Variables from *.appenv.js / .env and Utilities

Installation

npm i archappenv

Overview

Structure

The archappenv provides three modules: AppEnv, Services, and Utilities.

To access all modules:

// load it as an entry point of the whole module:
const { AppEnv } = require('archappenv');
const Services = AppEnv.Services;
const Utilities = AppEnv.Util;

To access each module:

// load it as separated module:
const AppEnv = require('archappenv/appenv');
const Services = require('archappenv/services');
const Utilities = require('archappenv/util');

Modules

AppEnv

The AppEnv module provides services to Application Environment Variables: load() and bind().

AppEnv.load(options)

It loads Application Environment Variables using Options or Configuration.

Options:

Options is an object that allows to customize how AppEnv is loaded.

- dir: defines the directory contained *.appenv.js files and appenv.config.json file. It can be absolute or relative path. If omitted, it'll use [application]/appenv/ as default directory.

- type: defined the [type].appenv.js file in dir directory. If omitted, it'll resolve a value from appenv.config.json file in dir directory.

appenv.config.json

It defines type depended to the name of server where it's located. If the name cannot be resolved, it'll use default.appenv.js.

module.exports = {
  prod: [
    "hostname.01",
    "hostname.02",
    "hostname.03",
  ],
  dev: [
    "hostname.04",
    "hostname.05",
    "hostname.06",
  ],
};

If the server name, either hostname.01, hostname.02, or hostname.03, , it'll resolve prod as type, and expect prod.appenv.js file to be resolved.

However, if the server name, either hostname.04, hostname.05, or hostname.06, it'll resolve dev as type, and expect dev.appenv.js file to be resolved.

Example:

Files:
In [application]/configs:
  - appenv.config.json (as above)
  - prod.appenv.js
  - dev.appenv.js
  - custom.appenv.js

Note: If these four files were located in [application]/appenv directory, the options.dir could be omitted. However, they are, in this case, located in [application]/configs directory, the options.dir need to be defined.

Usage

// loads [application]/configs/prod.appenv.js
const prod = AppEnv.load({ type:'prod', dir: './configs' });

// loads [application]/configs/dev.appenv.js
const dev = AppEnv.load({ type:'dev', dir: './configs' });

// loads [application]/configs/custom.appenv.js
const custom = AppEnv.load({ type:'custom', dir: './configs' });

// loads [application]/configs/prod.appenv.js in "hostname.01" server
const prod = AppEnv.load({ dir: './configs' });

// loads [application]/appenv/prod.appenv.js in "hostname.01" server
const prod = AppEnv.load();

// loads [application]/appenv/dev.appenv.js in "hostname.04" server
const dev = AppEnv.load();

// loads [application]/appenv/default.appenv.js in "not.in.list.hostname" server
const default = AppEnv.load();

AppEnv.bind()

It binds the resolved Application Environment Variables to process.env.

// in resolved appenv.js file:
module.exports = {
  APP_TITLE: "Application Title",
  APP_USERS: [
    "user.01",
    "user.02",
    "user.03",
  ],
};

Usage

AppEnv.bind();

const title = process.env.APP_TITLE;
// title: "Application Title"

const users = process.env.APP_USERS;
// users: ["user.01", "user.02", "user.03"]

back to top

Services

Utilities