Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Dependency directories
node_modules/

# dotenv environment variables file
.env
.env.test

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# Other
debug.js
erik.js
eslintrc.json
smell.java
README.node_modules
smell.java
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ git clone https://github.com/yy2111/REST

Go to your profile page on github, select "Settings" --> "Developer settings" --> "Personal access tokens", and then click on "Generate new token" button.

Save your token in an [environment variable]. This step may be a little tricky, and please read instructions on this page carefully: https://github.com/chrisparnin/EngineeringBasics/blob/master/Shells.md#environment-variables.

```bash
# Mac/Linux
export GITHUBTOKEN="xxx"
# Windows
setx GITHUBTOKEN xxx
Create a file `.env` in the root of the project and add your access token.
```
GITHUBTOKEN=abc123
```

> **Do not** push the `.env` file to github. This will expose your Github token.

### 2. Test sample code

Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var urlRoot = "https://api.github.com";

var userId = "yy2111";
var config = {};

// Retrieve our api token from the environment variables.
require('dotenv').config();
config.token = process.env.GITHUBTOKEN;

if( !config.token )
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Practice with REST concepts.",
"scripts": {
"start": "node index.js",
"test": "mocha --reporter spec"
},
"main": "index.js",
Expand All @@ -11,6 +12,7 @@
],
"dependencies": {
"chalk": "^2.4.2",
"dotenv": "^8.2.0",
"parse-link-header": "^1.0.1",
"request": "^2.88.0",
"unirest": "^0.6.0"
Expand Down