-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
51 lines (45 loc) · 2.04 KB
/
Copy pathapp.js
File metadata and controls
51 lines (45 loc) · 2.04 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const http = require('http');
const {LokaliseAPI} = require('node-lokalise-api');
const port = process.env.PORT || 3000;
const host = process.env.HOST || 'localhost';
const server = http.createServer(() => {
async function lokaliseDash() {
try {
const api = new LokaliseAPI({token: '620b7094823c3e398233a6a368847f39dc38c417'});
const {projects} = await api
.projects
.list({page: 1, limit: 100});
try {
contributorsList, translations_list = [];
for (const project of projects) {
if (project.project_id) {
const translations = await api.translations.list(project.project_id, {page: 1, limit: 100});
translations_list = [...translations_list,...translations];
const {contributors} = await api.contributors.list(project.project_id, {page: 1,limit: 1000});
if (contributorsList.length > 0) {
const contributorsNew = contributors.reduce((accumulator, newCon) => {
const exist = contributorsList.find((oldCon) => (oldCon.user_id === newCon.user_id) && oldCon)
if (!exist) {
accumulator.push(newCon);
}
return accumulator;
}, []);
contributorsList = [...contributorsList,...contributorsNew];
} else {
contributorsList = [...contributorsList,...contributors];
}
}
}
console.log(contributorsList);
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
}
lokaliseDash();
});
server.listen(port, () => {
console.log(`The Port is open on ${port} head to localhost:${port} to access the site`);
});