Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
sails-js-hook-dotenv
Advanced tools
Sails JS hook to load environment variables from a .env
file
using dotenv
npm install sails-js-hook-dotenv
Start sails as you normally do (sails lift
) and you will be able to access your environment variables
using process.env.your-variable-name
You can add configuration options for this hook in config/dotenv.js
by default.
module.exports.dotenv = {
default: {
/**
* Setting this to false will disable this hook
*
* Default: true
*/
active: true,
/**
* Setting this to false will cause the application
* NOT to throw an error if the config fails to load
*
* Default: true
*/
throwOnFailure: true,
/**
* Specify a custom path if your file containing
* environment variables is located elsewhere.
*
* Default: path.resolve(process.cwd(), '.env')
*/
path: '/custom/path/to/.env',
/**
* Specify the encoding of your file containing
* environment variables.
*
* Default: utf8
*/
encoding: 'latin1',
/**
* Turn on logging to help debug why certain keys
* or values are not being set as you expect.
*
* Default: false
*/
debug: true,
/**
* Override any environment variables that have
* already been set on your machine with values
* from your .env file.
*
* Default: false
*/
override: true,
}
}
Copy the .env.example
file to create a new .env
file.
Then run npm run test
in your terminal.
FAQs
Sails.js hook for loading .env files
We found that sails-js-hook-dotenv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.