Skip to content

Commit e9a6e38

Browse files
committed
updated authentication of GitHub API
1 parent 0a0bc07 commit e9a6e38

File tree

7 files changed

+9
-81
lines changed

7 files changed

+9
-81
lines changed

book/6-end/server/github.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,7 @@ function setupGithub({ server }) {
7878
}
7979

8080
function getAPI({ accessToken }) {
81-
const github = new GithubAPI({
82-
timeout: 5000,
83-
baseUrl: 'https://api.github.com',
84-
headers: {
85-
accept: 'application/json',
86-
},
87-
requestMedia: 'application/json',
88-
});
89-
90-
github.authenticate({
91-
type: 'oauth',
92-
token: accessToken,
93-
});
81+
const github = new GithubAPI({ auth: accessToken, request: { timeout: 10000 } });
9482

9583
return github;
9684
}

book/7-begin/server/github.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,7 @@ function setupGithub({ server }) {
7777
}
7878

7979
function getAPI({ accessToken }) {
80-
const github = new GithubAPI({
81-
timeout: 5000,
82-
baseUrl: 'https://api.github.com',
83-
headers: {
84-
accept: 'application/json',
85-
},
86-
requestMedia: 'application/json',
87-
});
88-
89-
github.authenticate({
90-
type: 'oauth',
91-
token: accessToken,
92-
});
80+
const github = new GithubAPI({ auth: accessToken, request: { timeout: 10000 } });
9381

9482
return github;
9583
}

book/7-end/server/github.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,7 @@ function setupGithub({ server }) {
7777
}
7878

7979
function getAPI({ accessToken }) {
80-
const github = new GithubAPI({
81-
timeout: 5000,
82-
baseUrl: 'https://api.github.com',
83-
headers: {
84-
accept: 'application/json',
85-
},
86-
requestMedia: 'application/json',
87-
});
88-
89-
github.authenticate({
90-
type: 'oauth',
91-
token: accessToken,
92-
});
80+
const github = new GithubAPI({ auth: accessToken, request: { timeout: 10000 } });
9381

9482
return github;
9583
}

book/8-begin/server/github.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,7 @@ function setupGithub({ server }) {
7777
}
7878

7979
function getAPI({ accessToken }) {
80-
const github = new GithubAPI({
81-
timeout: 5000,
82-
baseUrl: 'https://api.github.com',
83-
headers: {
84-
accept: 'application/json',
85-
},
86-
requestMedia: 'application/json',
87-
});
88-
89-
github.authenticate({
90-
type: 'oauth',
91-
token: accessToken,
92-
});
80+
const github = new GithubAPI({ auth: accessToken, request: { timeout: 10000 } });
9381

9482
return github;
9583
}

book/8-end/server/github.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,7 @@ function setupGithub({ server }) {
7777
}
7878

7979
function getAPI({ accessToken }) {
80-
const github = new GithubAPI({
81-
timeout: 5000,
82-
baseUrl: 'https://api.github.com',
83-
headers: {
84-
accept: 'application/json',
85-
},
86-
requestMedia: 'application/json',
87-
});
88-
89-
github.authenticate({
90-
type: 'oauth',
91-
token: accessToken,
92-
});
80+
const github = new GithubAPI({ auth: accessToken, request: { timeout: 10000 } });
9381

9482
return github;
9583
}

server/github.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,7 @@ function setupGithub({ server }) {
7979
}
8080

8181
function getAPI({ accessToken }) {
82-
const github = new GithubAPI({
83-
// debug: true,
84-
timeout: 0,
85-
baseUrl: 'https://api.github.com',
86-
headers: {
87-
accept: 'application/json',
88-
},
89-
requestMedia: 'application/json',
90-
});
91-
92-
github.authenticate({
93-
type: 'oauth',
94-
token: accessToken,
95-
});
82+
const github = new GithubAPI({ auth: accessToken, request: { timeout: 10000 } });
9683

9784
return github;
9885
}

server/models/EmailTemplate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ async function insertTemplates() {
6565

6666
if (count === 0) {
6767
EmailTemplate.create(Object.assign({}, t, {
68-
message: t.message.replace(/\n/g, '').replace(/[ ]+/g, ' '),
69-
}));
68+
message: t.message.replace(/\n/g, '').replace(/[ ]+/g, ' '),
69+
}),
70+
);
7071
}
7172
}
7273
}

0 commit comments

Comments
 (0)