Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit 98150f4

Browse files
committed
0.1-alpha
1 parent 5efaf69 commit 98150f4

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
package-lock.json
3+
node_modules

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# codeline-statistic
22
Parse the lines of code for each language in the repository and generate the results. (using nodeJS)
3+
4+
5+
# Initialization
6+
```shell
7+
npm install
8+
```

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const express = require('express');
2+
const axios = require('axios');
3+
const app = express();
4+
5+
async function syncAxios(url) {
6+
return (await axios.get(url)).data;
7+
}
8+
9+
async function getLanguage(user, repo) {
10+
return await syncAxios(`https://api.github.com/repos/${user}/${repo}/languages`);
11+
}
12+
app.get('/user/:user/', async function (req, res) {
13+
const username = req.params.user;
14+
const response = await syncAxios(`https://api.github.com/users/${username}/repos`);
15+
const statistic = Object.values(response).map(async (resp) => {
16+
return await getLanguage(username, resp['name']);
17+
});
18+
res.send(statistic);
19+
})
20+
21+
app.get('/repo/:user/:repo/', function (req, res) {
22+
res.send(getLanguage(req.params['user'], req.params['repo']));
23+
})
24+
25+
app.listen(3000);

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "codeline-statistic",
3+
"version": "1.0.0",
4+
"description": "Parse the lines of code for each language in the repository/account and generate the results. ",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/zmh-program/codeline-statistic.git"
12+
},
13+
"keywords": [
14+
"line-statistic"
15+
],
16+
"author": "zmh-program",
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/zmh-program/codeline-statistic/issues"
20+
},
21+
"homepage": "https://github.com/zmh-program/codeline-statistic#readme",
22+
"dependencies": {
23+
"axios": "^1.3.2",
24+
"express": "^4.18.2"
25+
}
26+
}

0 commit comments

Comments
 (0)