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

dotconfigure

v2.0.1

Published

Simple zero-dependency module that loads enviroment variables.

Downloads

4

Readme

Dotconfig was inspired by dotenv, all credit goes towards them for the idea.

NPM Package: https://www.npmjs.com/package/dotconfigure GitHub Repository: https://github.com/GabrielGavrilov/dotconfig

dotconfig

Dotconfig is a simple lightweight zero-dependency module that allows developers to create enviroment variables in a .config file. No more having to store your enviroment variables inside your source, start storing them somewhere safer with dotconfig!

Install

to install dotconfig locally via node package manager.

npm install dotconfigure --save

Usage

Create a .config file in the root of your project, here is where we will be storing all the variables inside this file.

and as early as possible, import dotconfig into your application:

const config = require('dotconfigure')

Variables

Creating variables:

VARIABLE_DATA_TYPE=VARIABLE_NAME=value

With dotconfig, we first define our variable, followed up with our variable name and value. You might have noticed that we used all captial characters for data type and the variable definition. Although this might be the standard for dotconfig, data types, and variable definitions are not case sensitive, so if you prefer using lower case characters, then by all means.

Dotconfig currently supports three different data types:

  • Strings
  • Numbers
  • Booleans

Creating string enviroment variables

To create a string enviroment variables:

STRING=SERVER_HOST=localhost

If we call this by config.SERVER_HOST it will output "localhost"

Creating number enviroment variables:

To create an enviroment variable that's a integer:

NUMBER=SERVER_PORT=3000

If we call this by config.SERVER_PORT it will output 3000

Creating boolean enviroment variables:

To create boolean enviroment variables:

BOOLEAN=TEST_MODE=True

If we call this by config.TEST_MODE it will output true

Note: boolean values are case insentivive. if the value would have been all caps, dotconfig would have still read it as "true" or "false".

Calling the enviroment variables

Calling the enviroment variables is even easier than making them. If you havent already, require dotconfig onto your application.

const config = require('dotconfigure')

Once we have dotconfig required, and some enviroment variables set, we would be able to start using them. For the example, lets say that we want to start an express server with the variables we just created.

app.listen(config.SERVER_PORT, config.SERVER_HOST, (err)=> {
    if(err) throw err;
    console.log(`Server is listening @ port ${config.SERVER_PORT}`);
})

And thats it. Dotconfig is a very simple package module that isn't hard to learn at all. Honestly, this took me under an hour initially make, hope you guys enjoy.