Socket
Socket
Sign inDemoInstall

feathers-configuration

Package Overview
Dependencies
5
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    feathers-configuration

A small configuration module for your Feathers application.


Version published
Weekly downloads
429
decreased by-6.33%
Maintainers
3
Install size
272 kB
Created
Weekly downloads
 

Changelog

Source

v0.4.0 (2016-10-22)

Full Changelog

Implemented enhancements:

  • implement node-config #27 (slajax)

Closed issues:

  • Deprecate v1 in favour of node-config #25
  • Make this repo more about managing configuration #24

Readme

Source

feathers-configuration

Build Status

A small configuration module for your Feathers application.

About

This release of feathers-configuration simply acts as a wrapped around node-config.

By default this implementation will look in config/* for default.json.

As per the config docs this is highly configurable.

Future releases will also include adapters for external configuration storage.

Usage

The feathers-configuration module is an app configuration function that takes a root directory (usually something like __dirname in your application) and the configuration folder (set to config by default):

import feathers from 'feathers';
import configuration from 'feathers-configuration';

// Use the current folder as the root and look configuration up in `settings`
let app = feathers().configure()

Example

In config/default.json we want to use the local development environment and default MongoDB connection string:

{
  "frontend": "../public",
  "host": "localhost",
  "port": 3030,
  "mongodb": "mongodb://localhost:27017/myapp",
  "templates": "../templates"
}

In config/production.js we are going to use environment variables (e.g. set by Heroku) and use public/dist to load the frontend production build:

{
  "frontend": "./public/dist",
  "host": "myapp.com",
  "port": "PORT",
  "mongodb": "MONGOHQ_URL"
}

Now it can be used in our app.js like this:

import feathers from 'feathers';
import configuration from 'feathers-configuration';

let conf = configuration();

let app = feathers()
  .configure(conf);

console.log(app.get('frontend'));
console.log(app.get('host'));
console.log(app.get('port'));
console.log(app.get('mongodb'));
console.log(app.get('templates'));
console.log(conf());

If you now run

node app
// -> path/to/app/public
// -> localhost
// -> 3030
// -> mongodb://localhost:27017/myapp
// -> path/to/templates

Or via custom environment variables by setting them in config/custom-environment-variables.json:

{
  "port": "PORT",
  "mongodb": "MONGOHQ_URL"
}
PORT=8080 MONGOHQ_URL=mongodb://localhost:27017/production NODE_ENV=production node app
// -> path/to/app/public/dist
// -> myapp.com
// -> 8080
// -> mongodb://localhost:27017/production
// -> path/to/templates

You can also override these variables with arguments. Read more about how with node-config

License

Copyright (c) 2015

Licensed under the MIT license.

Keywords

FAQs

Last updated on 22 Oct 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc