From e20b33d4e132f951fb85a3dba4e3f82d9fb370ff Mon Sep 17 00:00:00 2001 From: Madison C Sharps Date: Wed, 5 Oct 2016 11:22:14 -0500 Subject: [PATCH 1/9] remove unused line and update readme --- README.md | 9 ++++++--- lib/Twitter.js | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f79a4d0..1bfe368 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,12 @@ You need to create a [Twitter app](https://dev.twitter.com/apps) to use the API. "callBackUrl": "XXX" } - // make a directory in the root folder of your project called data - // copy the node_modules/twitter-node-client/twitter_config file over into data/twitter_config` - // Open `data/twitter_config` and supply your applications `consumerKey`, 'consumerSecret', 'accessToken', 'accessTokenSecret', 'callBackUrl' to the appropriate fields in your data/twitter_config file + // Create a .env file in the root of your project and supply your applications keys using key=value style e.g. + // twitterConsumerKey='xxx' + // twitterConsumerSecret='xxx' + // twitterAccessToken='xxx' + // twitterAccessTokenSecret='xxx' + // twitterCallBackUrl='xxx' var twitter = new Twitter(); diff --git a/lib/Twitter.js b/lib/Twitter.js index 88bdfd8..2a78eec 100644 --- a/lib/Twitter.js +++ b/lib/Twitter.js @@ -6,7 +6,6 @@ var OAuth = require('oauth').OAuth; var qs = require('qs'); function Twitter() { - var configPath = "data/twitter_config"; try { var config = process.env; From b219f48ee8979c3ea7e4d29aa57ef18267d7ac8c Mon Sep 17 00:00:00 2001 From: Madison C Sharps Date: Wed, 5 Oct 2016 11:52:18 -0500 Subject: [PATCH 2/9] add dotenv package so that .env will be read from root. update readme --- .env | 5 + README.md | 2 +- lib/Twitter.js | 2 +- node_modules/dotenv/.npmignore | 6 + node_modules/dotenv/CHANGELOG.md | 43 ++++++ node_modules/dotenv/CONTRIBUTING.md | 25 ++++ node_modules/dotenv/LICENSE | 23 ++++ node_modules/dotenv/README.md | 206 ++++++++++++++++++++++++++++ node_modules/dotenv/config.js | 11 ++ node_modules/dotenv/dotenv.png | Bin 0 -> 5009 bytes node_modules/dotenv/lib/main.js | 82 +++++++++++ node_modules/dotenv/package.json | 71 ++++++++++ package.json | 19 +-- 13 files changed, 485 insertions(+), 10 deletions(-) create mode 100644 .env create mode 100644 node_modules/dotenv/.npmignore create mode 100644 node_modules/dotenv/CHANGELOG.md create mode 100644 node_modules/dotenv/CONTRIBUTING.md create mode 100644 node_modules/dotenv/LICENSE create mode 100644 node_modules/dotenv/README.md create mode 100644 node_modules/dotenv/config.js create mode 100644 node_modules/dotenv/dotenv.png create mode 100644 node_modules/dotenv/lib/main.js create mode 100644 node_modules/dotenv/package.json diff --git a/.env b/.env new file mode 100644 index 0000000..178404f --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +twitterConsumerKey='xxx' +twitterConsumerSecret='xxx' +twitterAccessToken='xxx' +twitterAccessTokenSecret='xxx' +twitterCallBackUrl='xxx' \ No newline at end of file diff --git a/README.md b/README.md index 1bfe368..d79397c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ You need to create a [Twitter app](https://dev.twitter.com/apps) to use the API. // twitterAccessToken='xxx' // twitterAccessTokenSecret='xxx' // twitterCallBackUrl='xxx' - + // an example .env file is included in the root of this project. make sure to gitignore this file when committing. var twitter = new Twitter(); //Example calls diff --git a/lib/Twitter.js b/lib/Twitter.js index 2a78eec..1b4ef02 100644 --- a/lib/Twitter.js +++ b/lib/Twitter.js @@ -4,7 +4,7 @@ var OAuth = require('oauth').OAuth; var qs = require('qs'); - +var dotenv = require('dotenv').config(); function Twitter() { try { var config = process.env; diff --git a/node_modules/dotenv/.npmignore b/node_modules/dotenv/.npmignore new file mode 100644 index 0000000..8278783 --- /dev/null +++ b/node_modules/dotenv/.npmignore @@ -0,0 +1,6 @@ +coverage/ +examples/ +test/ +.editorconfig +.travis.yml +Contributing.md diff --git a/node_modules/dotenv/CHANGELOG.md b/node_modules/dotenv/CHANGELOG.md new file mode 100644 index 0000000..87dd001 --- /dev/null +++ b/node_modules/dotenv/CHANGELOG.md @@ -0,0 +1,43 @@ +# Change Log +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] + +## [2.0.0] - 2016-01-20 +### Added +- CHANGELOG to ["make it easier for users and contributors to see precisely what notable changes have been made between each release"](http://keepachangelog.com/). Linked to from README +- LICENSE to be more explicit about what was defined in `package.json`. Linked to from README +- Testing nodejs v4 on travis-ci +- added examples of how to use dotenv in different ways +- return parsed object on success rather than boolean true + +### Changed +- README has shorter description not referencing ruby gem since we don't have or want feature parity + +### Removed +- Variable expansion and escaping so environment variables are encouraged to be fully orthogonal + +## [1.2.0] - 2015-06-20 +### Added +- Preload hook to require dotenv without including it in your code + +### Changed +- clarified license to be "BSD-2-Clause" in `package.json` + +### Fixed +- retain spaces in string vars + +## [1.1.0] - 2015-03-31 +### Added +- Silent option to silence `console.log` when `.env` missing + +## [1.0.0] - 2015-03-13 +### Removed +- support for multiple `.env` files. should always use one `.env` file for the current environment + +[Unreleased]: https://github.com/motdotla/dotenv/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0 +[1.2.0]: https://github.com/motdotla/dotenv/compare/v1.1.0...v1.2.0 +[1.1.0]: https://github.com/motdotla/dotenv/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/motdotla/dotenv/compare/v0.4.0...v1.0.0 diff --git a/node_modules/dotenv/CONTRIBUTING.md b/node_modules/dotenv/CONTRIBUTING.md new file mode 100644 index 0000000..04552a9 --- /dev/null +++ b/node_modules/dotenv/CONTRIBUTING.md @@ -0,0 +1,25 @@ +# Contributing + +1. Fork it +2. `npm install` +3. Create your feature branch (`git checkout -b my-new-feature`) +4. Commit your changes (`git commit -am 'Added some feature'`) +5. `npm test` +6. Push to the branch (`git push origin my-new-feature`) +7. Create new Pull Request + +## Testing + +We use [lab](https://github.com/hapijs/lab) and [should](https://github.com/shouldjs/should.js) to write BDD test. Run our test suite with this command: + +``` +npm test +``` + +## Code Style + +We use [standard](https://www.npmjs.com/package/standard) and [editorconfig](http://editorconfig.org) to maintain code style and best practices. Please make sure your PR adheres to the guides by running: + +``` +npm run lint +``` diff --git a/node_modules/dotenv/LICENSE b/node_modules/dotenv/LICENSE new file mode 100644 index 0000000..c430ad8 --- /dev/null +++ b/node_modules/dotenv/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2015, Scott Motte +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/dotenv/README.md b/node_modules/dotenv/README.md new file mode 100644 index 0000000..07a8c6a --- /dev/null +++ b/node_modules/dotenv/README.md @@ -0,0 +1,206 @@ +# dotenv + +dotenv + +Dotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology. + +[![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv) +[![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv) +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) + +## Install + +```bash +npm install dotenv --save +``` + +## Usage + +As early as possible in your application, require and configure dotenv. + +```javascript +require('dotenv').config(); +``` + +Create a `.env` file in the root directory of your project. Add +environment-specific variables on new lines in the form of `NAME=VALUE`. +For example: + +``` +DB_HOST=localhost +DB_USER=root +DB_PASS=s1mpl3 +``` + +That's it. + +`process.env` now has the keys and values you defined in your `.env` file. + +```javascript +db.connect({ + host: process.env.DB_HOST, + username: process.env.DB_USER, + password: process.env.DB_PASS +}); +``` + +### Preload + +If you are using iojs-v1.6.0 or later, you can use the `--require` (`-r`) command line option to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. + + +```bash +$ node -r dotenv/config your_script.js +``` + +The configuration options below are supported as command line arguments in the format `dotenv_config_