sails-js-hook-dotenv
Sails JS hook to load environment variables from a .env
file using dotenv
Installation
npm install sails-hook-dotenv
Usage
Start sails as you normally do (sails lift
) and you will be able to access your environment variables using process.env.your-variable-name
Configuration
You can add configuration options for this hook in config/dotenv.js
by default. Currently, the only option is a boolean: active
. Setting this to false will disable this hook.
module.exports.dotenv = {
default: {
active: true,
throwOnFailure: true,
}
}
Testing
Copy the .env.example
file to create a new .env
file.
Then run npm run test
in your terminal.
Changelog
Changelog
1.0.3
-Removing dependency on should package by @ActuallyConnor in https://github.com/ActuallyConnor/sails-js-hook-dotenv/pull/4
-Fixing README.md by @ActuallyConnor in https://github.com/ActuallyConnor/sails-js-hook-dotenv/pull/3
-Migrating to ES6 syntax by @ActuallyConnor in https://github.com/ActuallyConnor/sails-js-hook-dotenv/pull/5
Full Changelog: https://github.com/ActuallyConnor/sails-js-hook-dotenv/compare/1.0.2...1.0.3