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

simple-conf

v0.0.5

Published

really easy to use config object, extends with underscore

Downloads

5

Readme

simple-conf

easy to use config object for your node.js app

Installation

Step 1) npm install git+https://github.com/dhigginbotham/simple-conf --save

Step 2) view /examples/config.coffee (or copy and paste to your app)

Step 3) require the config.coffee folder inside your app somewhere and console.log

Heads up!

simple-conf is set to look for a couple environment vars by default, although, if you don't want to set these it will set some defaults instead..

  • process.env.NODE_PASS, this will set your initial seed admin password and keep this sensitive stuff out of your repo. defaults to: superSecretPassWordDawgz1!2@

  • process.env.MONGO_DB_STRING, this will link up your mongodb url, good for production and public repos

  • I don't want to set these up! Oh, that's cool too -- it's not going to break, it's just there to help.

Config Helpers (new)

I've included a couple helpers that I use on my apps and find helpful -- maybe you will too?

extended - requires req good for middleware, or schema stuff that has access to req, adds:

  • ip = req.headers["x-forwarded-for"] or req.connection.remoteAddress
  • user = if req.user? then req.user.username else "anonymous"
  • engine = req.protocol + "://" + req.get('host')

folders - requires path & function (err, path)

  • adds folders easily so you don't have to deal with .placeholder files and whatnot

colors - no requirements

  • red outputs red font color to stdout
  • cyan outputs cyan font color to stdout
  • reset resets font color to stdout

Example


Config = require ".."

fs = require "fs"
path = require "path"

env = process.env.NODE_ENV

port = if env == "production" then process.env.port else 3000
host = if env == "development" then "http://localhost:#{port}" 

production = env == "production"
development = env == "development"

config =
  api:
    github:
      username: "dhigginbotham"
    coderbits:
      username: "dhz"
  app:
    title: "example-app"
    initials: "xpl"
    port: port
    host: host
    serverStart: "Starting up your express engines"
    paths: 
      uploads: path.join __dirname, "..", "public", "uploads"
      views: path.join __dirname, "..", "views"
      assets: path.join __dirname, "..", "public"
  seed:
    init: if production == true then false else true
  debug:
    mongo: if production == true then false else false

conf = new Config config

if conf.debug.config == true then console.log conf

module.exports = conf

Defaults

note - defaults are now optional, ex: new Config object, false renders a more modular config for mountable apps.


  @app = {}
  @app.title = "Default-config-build"
  @app.initials = "dcb"
  @app.port = process.env.port || 3000
  @app.host = "http://localhost#{@app.port}"
  @app.serverStart = "Starting express server "

  @db = {}
  @db.path = "#{@app.initials}"
  @db.url = process.env.MONGO_DB_STRING || "mongodb://localhost/#{@db.path}"

  @sesh = {}
  @sesh.key = "#{@app.initials}.id"
  @sesh.secret = _secret
  @sesh.maxAge = 60 * 60 * 1000

  @seed = {}
  @seed.init = false
  @seed.folders = true

  @users = {}
  @users.roles = ['user', 'admin', 'editor', 'commenter']
  @users.signupEnabled = true

  @debug = {}
  @debug.override = false

  if opts? then _.extend @, opts

  if @seed.init == true
    @seed.user = {}
    @seed.user.username = "admin"
    @seed.user.password = "@dminPassw0rd"
    @seed.user.admin = true
    @seed.user.role = "admin"
    @seed.user.email = "[email protected]"
    @seed.user.ip = "admin.ipv6"

  @

License


The MIT License (MIT)

Copyright (c) 2013 David Higginbotham 

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.