If you need to push your code to github for a node.js app that uses the Twitter API, here are the steps that you can take to protect your keys, by using gitignore.
- Create a separate file that stores your api keys, let’s call it twitterKeys.js
- Require the twitterKeys.js files in the file that you wish to extract data required using the API.
var keys = require('./server/twitterKeys');
- Now that you ‘required’ the file that contains your Twitter API credentials, you can access them as properties of the keys variable you created above.
- Be sure to add your file that contains your personal information to the gitignore file, before you push your code to GitHub.