@20syldev/api 2.7.0 → 2.8.0
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 +45 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<a href="https://api.sylvain.pro"><img src="https://api.sylvain.pro/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
|
---
|
|
@@ -17,7 +17,7 @@ L'API est développée avec Node.js et hébergée **24h/7j**. Elle est **simple
|
|
|
17
17
|
$ npm run build
|
|
18
18
|
```
|
|
19
19
|
```console
|
|
20
|
-
> @20syldev/api@2.
|
|
20
|
+
> @20syldev/api@2.8.0 build
|
|
21
21
|
> npm install && node app.js
|
|
22
22
|
|
|
23
23
|
[...]
|
package/app.js
CHANGED
|
@@ -15,9 +15,12 @@ const random = require('random');
|
|
|
15
15
|
const uuid = require('uuid');
|
|
16
16
|
const app = express();
|
|
17
17
|
|
|
18
|
-
// Define allowed versions & endpoints
|
|
19
|
-
const versions = ['v1'];
|
|
20
|
-
const endpoints =
|
|
18
|
+
// Define allowed versions & endpoints for each version
|
|
19
|
+
const versions = ['v1', 'v2'];
|
|
20
|
+
const endpoints = {
|
|
21
|
+
v1: ['algorithms', 'captcha', 'color', 'convert', 'domain', 'infos', 'personal', 'qrcode', 'token', 'username', 'website'],
|
|
22
|
+
v2: ['algorithms', 'captcha', 'chat', 'color', 'convert', 'domain', 'hash', 'infos', 'personal', 'qrcode', 'tic-tac-toe', 'token', 'username', 'website']
|
|
23
|
+
};
|
|
21
24
|
|
|
22
25
|
// Store data
|
|
23
26
|
const logs = [], chat = [], privateChats = {}, sessions = {}, rateLimits = {}, games = {};
|
|
@@ -112,7 +115,7 @@ app.use('/:version', (req, res, next) => {
|
|
|
112
115
|
app.use('/:version/:endpoint', (req, res, next) => {
|
|
113
116
|
const { version, endpoint } = req.params;
|
|
114
117
|
|
|
115
|
-
if (!versions.includes(version) || !endpoints.includes(endpoint)) {
|
|
118
|
+
if (!versions.includes(version) || !endpoints[version].includes(endpoint)) {
|
|
116
119
|
return res.status(404).jsonResponse({
|
|
117
120
|
message: 'Not Found',
|
|
118
121
|
error: `Endpoint '${endpoint}' does not exist in ${version}.`,
|
|
@@ -133,7 +136,8 @@ app.get('/', (req, res) => {
|
|
|
133
136
|
latest: 'https://api.sylvain.pro/latest',
|
|
134
137
|
logs: 'https://api.sylvain.pro/logs',
|
|
135
138
|
versions: {
|
|
136
|
-
v1: 'https://api.sylvain.pro/v1'
|
|
139
|
+
v1: 'https://api.sylvain.pro/v1',
|
|
140
|
+
v2: 'https://api.sylvain.pro/v2'
|
|
137
141
|
}
|
|
138
142
|
});
|
|
139
143
|
});
|
|
@@ -146,7 +150,6 @@ app.get('/v1', (req, res) => {
|
|
|
146
150
|
get: {
|
|
147
151
|
algorithm: '/v1/algorithms?method={algorithm}&value={value}(&value2={value2})',
|
|
148
152
|
captcha: '/v1/captcha?text={text}',
|
|
149
|
-
chat: '/v1/chat',
|
|
150
153
|
color: '/v1/color',
|
|
151
154
|
convert: '/v1/convert?value={value}&from={unit}&to={unit}',
|
|
152
155
|
domain: '/v1/domain',
|
|
@@ -156,14 +159,45 @@ app.get('/v1', (req, res) => {
|
|
|
156
159
|
username: '/v1/username'
|
|
157
160
|
},
|
|
158
161
|
post: {
|
|
159
|
-
chat: '/v1/chat',
|
|
160
|
-
hash: '/v1/hash',
|
|
161
162
|
token: '/v1/token'
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
167
|
|
|
168
|
+
// Display v2 endpoints
|
|
169
|
+
app.get('/v2', (req, res) => {
|
|
170
|
+
res.jsonResponse({
|
|
171
|
+
version: 'v2',
|
|
172
|
+
endpoints: {
|
|
173
|
+
get: {
|
|
174
|
+
algorithm: '/v2/algorithms?method={algorithm}&value={value}(&value2={value2})',
|
|
175
|
+
captcha: '/v2/captcha?text={text}',
|
|
176
|
+
chat: '/v2/chat',
|
|
177
|
+
color: '/v2/color',
|
|
178
|
+
convert: '/v2/convert?value={value}&from={unit}&to={unit}',
|
|
179
|
+
domain: '/v2/domain',
|
|
180
|
+
infos: '/v2/infos',
|
|
181
|
+
personal: '/v2/personal',
|
|
182
|
+
qrcode: '/v2/qrcode?url={URL}',
|
|
183
|
+
username: '/v2/username'
|
|
184
|
+
},
|
|
185
|
+
post: {
|
|
186
|
+
chat: {
|
|
187
|
+
chat: '/v2/chat',
|
|
188
|
+
private: '/v2/chat/private'
|
|
189
|
+
},
|
|
190
|
+
hash: '/v2/hash',
|
|
191
|
+
tic_tac_toe: {
|
|
192
|
+
tic_tac_toe: '/v2/tic-tac-toe',
|
|
193
|
+
fetch: '/v2/tic-tac-toe/fetch'
|
|
194
|
+
},
|
|
195
|
+
token: '/v2/token'
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
167
201
|
// Display logs
|
|
168
202
|
app.get('/logs', (req, res) => res.jsonResponse(logs));
|
|
169
203
|
|
|
@@ -651,13 +685,16 @@ app.get('/:version/website', async (req, res) => {
|
|
|
651
685
|
doc_coopbot: process.env.DOC_COOPBOT,
|
|
652
686
|
docs: process.env.DOCS,
|
|
653
687
|
donut: process.env.DONUT,
|
|
688
|
+
drawio_plugin: process.env.DRAWIO_PLUGIN,
|
|
654
689
|
flowers: process.env.FLOWERS,
|
|
655
690
|
gemsync: process.env.GEMSYNC,
|
|
656
691
|
gitsite: process.env.GITSITE,
|
|
657
692
|
logs: process.env.LOGS,
|
|
693
|
+
morpion: process.env.MORPION,
|
|
658
694
|
nitrogen: process.env.NITROGEN,
|
|
659
695
|
old_database: process.env.OLD_DATABASE,
|
|
660
696
|
php: process.env.PHP,
|
|
697
|
+
ping: process.env.PING,
|
|
661
698
|
portfolio: process.env.PORTFOLIO,
|
|
662
699
|
python_api: process.env.PYTHON_API,
|
|
663
700
|
readme: process.env.README,
|
package/package.json
CHANGED