summaryrefslogtreecommitdiff
path: root/graphs/js/notSoFast
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/js/notSoFast
add: graphs et rushs
Diffstat (limited to 'graphs/js/notSoFast')
-rw-r--r--graphs/js/notSoFast/articles.json74
-rw-r--r--graphs/js/notSoFast/notSoFast.js33
-rw-r--r--graphs/js/notSoFast/server.js147
3 files changed, 254 insertions, 0 deletions
diff --git a/graphs/js/notSoFast/articles.json b/graphs/js/notSoFast/articles.json
new file mode 100644
index 0000000..5ffb5fb
--- /dev/null
+++ b/graphs/js/notSoFast/articles.json
@@ -0,0 +1,74 @@
+[
+ {
+ "id":0,
+ "name": "Cheeseburger",
+ "description": "Beef patty, melted cheese, ketchup, mustard, pickles",
+ "price": 4.99,
+ "customer_note": 4.5,
+ "stocks": 20
+ },
+ {
+ "id":1,
+ "name": "Fries",
+ "description": "Crispy, golden-brown potato sticks",
+ "price": 2.49,
+ "customer_note": 4.0,
+ "stocks": 50
+ },
+ {
+ "id":2,
+ "name": "Hot Dog",
+ "description": "Grilled all-beef frankfurter, topped with ketchup, mustard, and relish",
+ "price": 3.99,
+ "customer_note": 3.5,
+ "stocks": 15
+ },
+ {
+ "id":3,
+ "name": "Chicken Nuggets",
+ "description": "Crispy breaded chicken bites, perfect for dipping",
+ "price": 5.99,
+ "customer_note": 4.2,
+ "stocks": 30
+ },
+ {
+ "id":4,
+ "name": "Milkshake",
+ "description": "Thick and creamy vanilla milkshake, made with real ice cream",
+ "price": 3.49,
+ "customer_note": 4.8,
+ "stocks": 10
+ },
+ {
+ "id":5,
+ "name": "BBQ Bacon Burger",
+ "description": "Beef patty, bacon, cheddar cheese, onion rings, BBQ sauce",
+ "price": 7.99,
+ "customer_note": 4.3,
+ "stocks": 5
+ },
+ {
+ "id":6,
+ "name": "Onion Rings",
+ "description": "Crispy fried onion rings, perfect as a side",
+ "price": 2.99,
+ "customer_note": 4.0,
+ "stocks": 40
+ },
+ {
+ "id":7,
+ "name": "Chicken Sandwich",
+ "description": "Grilled chicken breast, lettuce, tomato, mayo",
+ "price": 6.49,
+ "customer_note": 3.8,
+ "stocks": 25
+ },
+ {
+ "id":8,
+ "name": "Spicy Chicken Nuggets",
+ "description": "Crispy breaded chicken bites with a spicy kick",
+ "price": 6.99,
+ "customer_note": 4.5,
+ "stocks": 15
+ }
+] \ No newline at end of file
diff --git a/graphs/js/notSoFast/notSoFast.js b/graphs/js/notSoFast/notSoFast.js
new file mode 100644
index 0000000..113c8f6
--- /dev/null
+++ b/graphs/js/notSoFast/notSoFast.js
@@ -0,0 +1,33 @@
+const axios = require("axios");
+
+async function notSoFast(host, port) {
+ let nbArticles = await axios.get(`http://${host}:${port}/articles`);
+
+ nbArticles = nbArticles.data.message;
+
+ const articles = [];
+
+ if (0 + nbArticles === 0) {
+ return articles;
+ }
+
+ let res = await axios.get(`http://${host}:${port}/articles/${0}`);
+
+ articles.push(res.data);
+ for (let i = 1; i < 0 + nbArticles; i++) {
+ const delay = res.headers["x-ratelimit-reset"] * 1000 - Date.now();
+
+ if (res.headers["x-ratelimit-remaining"] == 0) {
+ await new Promise((oof) => setTimeout(oof, delay + 26));
+ }
+
+ res = await axios.get(`http://${host}:${port}/articles/${i}`);
+ articles.push(res.data);
+ }
+
+ return articles;
+}
+
+module.exports = {
+ notSoFast,
+};
diff --git a/graphs/js/notSoFast/server.js b/graphs/js/notSoFast/server.js
new file mode 100644
index 0000000..916c7d8
--- /dev/null
+++ b/graphs/js/notSoFast/server.js
@@ -0,0 +1,147 @@
+const _0x56061b = _0x4a1f;
+
+(function (_0x3d4f7d, _0x384467) {
+ const _0x2bc30d = _0x4a1f,
+ _0x2a57c0 = _0x3d4f7d();
+
+ while ([]) {
+ try {
+ const _0x509389 =
+ parseInt(_0x2bc30d(0xf9)) / 0x1 +
+ (-parseInt(_0x2bc30d(0xf8)) / 0x2) *
+ (parseInt(_0x2bc30d(0xf3)) / 0x3) +
+ parseInt(_0x2bc30d(0x100)) / 0x4 +
+ -parseInt(_0x2bc30d(0xef)) / 0x5 +
+ parseInt(_0x2bc30d(0xeb)) / 0x6 +
+ parseInt(_0x2bc30d(0xee)) / 0x7 +
+ (-parseInt(_0x2bc30d(0xe3)) / 0x8) *
+ (-parseInt(_0x2bc30d(0xf4)) / 0x9);
+
+ if (_0x509389 === _0x384467) {
+ break;
+ } else {
+ _0x2a57c0["push"](_0x2a57c0["shift"]());
+ }
+ } catch (_0x4f4837) {
+ _0x2a57c0["push"](_0x2a57c0["shift"]());
+ }
+ }
+})(_0x5ba1, 0x37cc5);
+const express = require(_0x56061b(0xfa)),
+ app = express(),
+ path = require("path");
+const articles_data = require(
+ path[_0x56061b(0xfd)](__dirname, _0x56061b(0xf7)),
+ ),
+ rateLimiter = {
+ max: 0x5,
+ windowMs: 0x3e8,
+ reset: Date[_0x56061b(0xe7)]() - 0x7d0,
+ remaining: 0x5,
+ };
+
+function _0x4a1f(_0xa5c9f4, _0x34d88a) {
+ const _0x5ba126 = _0x5ba1();
+
+ return (
+ (_0x4a1f = function (_0x4a1f4f, _0x57de0b) {
+ _0x4a1f4f = _0x4a1f4f - 0xe1;
+ const _0x91c04c = _0x5ba126[_0x4a1f4f];
+
+ return _0x91c04c;
+ }),
+ _0x4a1f(_0xa5c9f4, _0x34d88a)
+ );
+}
+function _0x5ba1() {
+ const _0x15e55c = [
+ "remaining",
+ "/articles",
+ "X-RateLimit-Reset",
+ "now",
+ "X-RateLimit-Remaining",
+ "\x20has\x20been\x20found",
+ "end",
+ "1185066KdUuVR",
+ "listen",
+ "send",
+ "1849449xJgCmq",
+ "1269280gTNiiN",
+ "get",
+ "reset",
+ "/articles/:id([0-9]+)",
+ "111uXMghV",
+ "72891SGOhSD",
+ "Too\x20many\x20requests",
+ "Server\x20running\x20at\x20http://localhost:",
+ "./articles.json",
+ "11996YaeIzr",
+ "64830rqNiDl",
+ "express",
+ "status",
+ "find",
+ "resolve",
+ "No\x20article\x20with\x20id\x20",
+ "max",
+ "678736fMeEWy",
+ "X-RateLimit-Limit",
+ "params",
+ "log",
+ "set",
+ "8YaqgyJ",
+ ];
+
+ _0x5ba1 = function () {
+ return _0x15e55c;
+ };
+ return _0x5ba1();
+}
+app[_0x56061b(0xf0)](_0x56061b(0xe5), (_0x53adb0, _0x2f6c36) => {
+ const _0x2e7227 = _0x56061b;
+
+ _0x2f6c36[_0x2e7227(0xfb)](0xc8)[_0x2e7227(0xed)]({
+ message: articles_data["length"],
+ });
+}),
+ app["get"](_0x56061b(0xf2), (_0x58952c, _0x1c1b41) => {
+ const _0x1800af = _0x56061b;
+
+ rateLimiter[_0x1800af(0xf1)] < Date[_0x1800af(0xe7)]() &&
+ ((rateLimiter["remaining"] = rateLimiter["max"]),
+ (rateLimiter["reset"] = Date["now"]() + rateLimiter["windowMs"]));
+ if (rateLimiter[_0x1800af(0xe4)] == 0x0) {
+ _0x1c1b41[_0x1800af(0xfb)](0x1ad)["send"](_0x1800af(0xf5));
+ return;
+ } else {
+ rateLimiter[_0x1800af(0xe4)]--;
+ }
+
+ const _0xca1069 = rateLimiter[_0x1800af(0xff)],
+ _0x5c15a1 = rateLimiter[_0x1800af(0xe4)],
+ _0x5d6b61 = parseFloat(rateLimiter[_0x1800af(0xf1)] / 0x3e8);
+
+ _0x1c1b41[_0x1800af(0xe2)](_0x1800af(0x101), _0xca1069),
+ _0x1c1b41[_0x1800af(0xe2)](_0x1800af(0xe8), _0x5c15a1),
+ _0x1c1b41[_0x1800af(0xe2)](_0x1800af(0xe6), _0x5d6b61);
+ const _0x413373 = articles_data[_0x1800af(0xfc)](
+ (_0x4868bf) =>
+ _0x4868bf["id"] === parseInt(_0x58952c[_0x1800af(0x102)]["id"]),
+ );
+
+ if (_0x413373) {
+ _0x1c1b41["status"](0xc8)["send"](_0x413373);
+ return;
+ } else {
+ _0x1c1b41["writeHead"](
+ 0x194,
+ _0x1800af(0xfe) +
+ _0x58952c[_0x1800af(0x102)]["id"] +
+ _0x1800af(0xe9),
+ );
+ }
+
+ _0x1c1b41[_0x1800af(0xea)]();
+ });
+const server = app[_0x56061b(0xec)](0xbb8, () => {});
+
+console[_0x56061b(0xe1)](_0x56061b(0xf6) + 0xbb8 + "/");