forked from mxstbr/micro-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (25 loc) · 814 Bytes
/
index.js
File metadata and controls
30 lines (25 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { router, get } = require("microrouter");
// Get Github Routes
const GithubAuth = require("./lib/GithubAuth");
/**
* Setup GH_CLIENT_ID and GH_CLIENT_SECRET.
* For security only allow setting by environment variables.
*/
const githubClientId = process.env.GH_CLIENT_ID;
const githubClientSecret = process.env.GH_CLIENT_SECRET;
/**
* Setup GH_HOST. Allow setting the domain for enterprise IDs.
* For security only allow setting by environment variables.
* If not set, default to github.com.
*/
const githubHost = process.env.GH_HOST;
// Initialize Github Auth with defaults
const app = new GithubAuth(githubClientId, githubClientSecret, {
githubUrl: githubHost,
});
// Export routes
module.exports = router(
get("/", app.login),
get("/login", app.login),
get("/callback", app.callback)
);