-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (33 loc) · 1 KB
/
index.js
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
31
32
33
34
35
36
37
const fs = require('fs')
const express = require('express')
const zoauth = require('zoauth')
const app = express()
let projects = JSON.parse(fs.readFileSync('projects.json'))
fs.readdirSync('../').forEach(file => {
if(!projects.initialized.includes(file)){
console.log(file)
}
})
app.listen(5210)
zoauth.setCredentials({
github: {
client_id: '',
scope: ['repo']
}
})
app.get('/', (req, resp) => {
resp.redirect(zoauth.getAuthUrl('github'))
})
app.get('/callback/github', (req, resp) => {
zoauth.getToken('github', {code: req.query.code}, {'headers': {'Accept': 'application/json'}})
.then(r1 => {
console.log(r1)
zoauth.postApi('https://api.github.com/user/repos', {
name: 'Test Repo',
description: 'Something something...',
private: true
}, r1)
.then(r2 => resp.send(r2))
.catch(err2 => resp.send(err2))
}).catch(err1 => resp.send(err1))
})