Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sails-js-hook-dotenv

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-js-hook-dotenv

Sails.js hook for loading .env files

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

sails-js-hook-dotenv

Sails JS hook to load environment variables from a .env file using dotenv

Installation

npm install sails-js-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.

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,

  }
}

Testing

Copy the .env.example file to create a new .env file.

Then run npm run test in your terminal.

Changelog

Changelog

Keywords

FAQs

Package last updated on 06 Apr 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc