forked from paularmstrong/normalizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 795 Bytes
/
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
import * as schema from './schema';
import fs from 'fs';
import https from 'https';
import { normalize } from '../../src';
import path from 'path';
let data = '';
const request = https.request(
{
host: 'api.github.com',
path: '/repos/paularmstrong/normalizr/issues',
method: 'get',
headers: {
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
}
},
(res) => {
res.on('data', (d) => {
data += d;
});
res.on('end', () => {
const normalizedData = normalize(JSON.parse(data), schema.issueOrPullRequest);
const out = JSON.stringify(normalizedData, null, 2);
fs.writeFileSync(path.resolve(__dirname, './output.json'), out);
});
res.on('error', (e) => {
console.log(e);
});
}
);
request.end();