@20syldev/api 3.4.7 → 3.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/app.js +41 -26
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a href="https://api.sylvain.sh"><img src="https://api.sylvain.sh/favicon.ico" alt="Logo" width="25%" height="auto"/></a>
|
|
3
3
|
|
|
4
4
|
# API Personnelle
|
|
5
|
-
[](https://github.com/20syldev/api/releases/latest)
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
---
|
|
@@ -72,7 +72,7 @@ Enfin, **exécutez** le script de build, qui installera les **dépendances** et
|
|
|
72
72
|
$ npm run build
|
|
73
73
|
```
|
|
74
74
|
```console
|
|
75
|
-
> @20syldev/api@3.4.
|
|
75
|
+
> @20syldev/api@3.4.9 build
|
|
76
76
|
> npm install && node app.js
|
|
77
77
|
|
|
78
78
|
[...]
|
package/app.js
CHANGED
|
@@ -107,7 +107,7 @@ const ticTacToeStorage = {
|
|
|
107
107
|
const documentation = 'https://docs.sylvain.sh';
|
|
108
108
|
|
|
109
109
|
// Define global variables
|
|
110
|
-
let
|
|
110
|
+
let activity = [], lastFetch = 0, requests = 0, requestLimit, resetTime = Date.now() + 3600000;
|
|
111
111
|
|
|
112
112
|
// ----------- ----------- MIDDLEWARES SETUP ----------- ----------- //
|
|
113
113
|
|
|
@@ -581,26 +581,21 @@ app.get('/:version/website', async (req, res) => {
|
|
|
581
581
|
try {
|
|
582
582
|
const username = '20syldev';
|
|
583
583
|
const token = process.env.GITHUB_TOKEN;
|
|
584
|
-
const today = new Date().toISOString().split('T')[0];
|
|
585
|
-
const monthFirst = new Date(new Date().getFullYear(), new Date().getMonth(), 1).toISOString().split('T')[0];
|
|
586
584
|
const lastYear = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).toISOString().split('T')[0];
|
|
587
585
|
|
|
588
586
|
const query = `
|
|
589
587
|
{
|
|
590
588
|
user(login: "${username}") {
|
|
591
|
-
contributionsCollection(from: "${
|
|
592
|
-
contributionCalendar {
|
|
593
|
-
totalContributions
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
contributions_month: contributionsCollection(from: "${monthFirst}T00:00:00Z") {
|
|
597
|
-
contributionCalendar {
|
|
598
|
-
totalContributions
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
contributions_year: contributionsCollection(from: "${lastYear}T00:00:00Z") {
|
|
589
|
+
contributionsCollection(from: "${lastYear}T00:00:00Z") {
|
|
602
590
|
contributionCalendar {
|
|
603
591
|
totalContributions
|
|
592
|
+
weeks {
|
|
593
|
+
firstDay
|
|
594
|
+
contributionDays {
|
|
595
|
+
date
|
|
596
|
+
contributionCount
|
|
597
|
+
}
|
|
598
|
+
}
|
|
604
599
|
}
|
|
605
600
|
}
|
|
606
601
|
}
|
|
@@ -617,18 +612,20 @@ app.get('/:version/website', async (req, res) => {
|
|
|
617
612
|
const data = await apiResponse.json();
|
|
618
613
|
const user = data?.data?.user;
|
|
619
614
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
615
|
+
const weeks = user?.contributionsCollection?.contributionCalendar?.weeks || [];
|
|
616
|
+
activity = weeks.map(w => ({
|
|
617
|
+
week: w.firstDay,
|
|
618
|
+
total: w.contributionDays.reduce((sum, d) => sum + d.contributionCount, 0),
|
|
619
|
+
days: w.contributionDays.map(d => ({ date: d.date, count: d.contributionCount }))
|
|
620
|
+
}));
|
|
625
621
|
|
|
626
622
|
lastFetch = currentTime;
|
|
627
|
-
} catch {
|
|
623
|
+
} catch { activity = []; }
|
|
628
624
|
}
|
|
629
625
|
|
|
630
|
-
|
|
626
|
+
const response = {
|
|
631
627
|
versions: {
|
|
628
|
+
2048: process.env.G_2048,
|
|
632
629
|
api: process.env.API,
|
|
633
630
|
cdn: process.env.CDN,
|
|
634
631
|
coop_api: process.env.COOP_API,
|
|
@@ -640,11 +637,11 @@ app.get('/:version/website', async (req, res) => {
|
|
|
640
637
|
donut: process.env.DONUT,
|
|
641
638
|
drawio_plugin: process.env.DRAWIO_PLUGIN,
|
|
642
639
|
flowers: process.env.FLOWERS,
|
|
643
|
-
2048: process.env["2048"],
|
|
644
640
|
gemsync: process.env.GEMSYNC,
|
|
645
641
|
gft: process.env.GFT,
|
|
646
642
|
gitsite: process.env.GITSITE,
|
|
647
643
|
lebonchar: process.env.LEBONCHAR,
|
|
644
|
+
logger: process.env.LOGGER,
|
|
648
645
|
logs: process.env.LOGS,
|
|
649
646
|
logvault: process.env.LOGVAULT,
|
|
650
647
|
lyah: process.env.LYAH,
|
|
@@ -677,13 +674,31 @@ app.get('/:version/website', async (req, res) => {
|
|
|
677
674
|
3: process.env.STATS3,
|
|
678
675
|
4: process.env.STATS4,
|
|
679
676
|
5: Object.keys(ipLimits).length,
|
|
680
|
-
|
|
681
|
-
this_month: contributions.month.toString(),
|
|
682
|
-
last_year: contributions.year.toString(),
|
|
677
|
+
activity
|
|
683
678
|
},
|
|
684
679
|
tag: process.env.TAG,
|
|
685
680
|
active: process.env.ACTIVE === 'true'
|
|
686
|
-
}
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
const key = req.query.key;
|
|
684
|
+
if (key) {
|
|
685
|
+
const keys = key.split('.');
|
|
686
|
+
let result = response;
|
|
687
|
+
|
|
688
|
+
for (const k of keys) {
|
|
689
|
+
if (result == null || typeof result !== 'object' || !(k in result)) {
|
|
690
|
+
return res.status(404).jsonResponse({
|
|
691
|
+
error: `Key '${key}' not found.`,
|
|
692
|
+
available: Object.keys(result ?? {})
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
result = result[k];
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return res.jsonResponse({ [key]: result });
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
res.jsonResponse(response);
|
|
687
702
|
});
|
|
688
703
|
|
|
689
704
|
// ----------- ----------- POST ENDPOINTS ----------- ----------- //
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.4.
|
|
2
|
+
"version": "3.4.9",
|
|
3
3
|
"name": "@20syldev/api",
|
|
4
4
|
"description": "Node.js API with multiple features. Check the documentation at https://docs.sylvain.sh",
|
|
5
5
|
"main": "app.js",
|
|
@@ -19,20 +19,20 @@
|
|
|
19
19
|
"./v3": "./modules/v3.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"canvas": "
|
|
23
|
-
"cors": "
|
|
24
|
-
"dotenv": "
|
|
25
|
-
"express": "
|
|
26
|
-
"ical.js": "
|
|
27
|
-
"node-fetch": "
|
|
28
|
-
"qrcode": "
|
|
29
|
-
"random": "
|
|
30
|
-
"uuid": "
|
|
22
|
+
"canvas": "^3.1.0",
|
|
23
|
+
"cors": "^2.8.5",
|
|
24
|
+
"dotenv": "^16.4.7",
|
|
25
|
+
"express": "^5.1.0",
|
|
26
|
+
"ical.js": "^2.1.0",
|
|
27
|
+
"node-fetch": "^3.3.2",
|
|
28
|
+
"qrcode": "^1.5.4",
|
|
29
|
+
"random": "^5.3.0",
|
|
30
|
+
"uuid": "^11.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"nodemon": "
|
|
34
|
-
"npm-check-updates": "
|
|
35
|
-
"prettier": "
|
|
33
|
+
"nodemon": "^3.1.10",
|
|
34
|
+
"npm-check-updates": "^18.0.1",
|
|
35
|
+
"prettier": "^3.5.3"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|