summaryrefslogtreecommitdiff
path: root/graphs/js/notSoFast/server.js
blob: 916c7d808cb37296e75bb38be02536abdf30b13b (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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 + "/");