/ Search - type / Modes - type M Star on GitHub - 5.7k

Docs

Sinatra

Encrypt a .env file in Sinatra with the Dotenvx gem, commit it safely, and load its secrets at runtime.

1. Install

Get the Dotenvx Ruby gem.
$ gem install dotenvx
And the CLI to encrypt files.
$ curl -sfS https://dotenvx.sh | sh

2. Encrypt

Encrypt your .env file.

$ dotenvx encrypt

3. Inject

Then inject your encrypted secrets at runtime.
require "dotenvx"
require "sinatra"

Dotenvx.load

get "/" do
  "HELLO: #{ENV['HELLO']}"
end