Skip to content

Commit

Permalink
Revert "testing with node-cache"
Browse files Browse the repository at this point in the history
This reverts commit 2695eaf.
  • Loading branch information
litsel-pitdyr committed Jan 6, 2025
1 parent 2695eaf commit 854c600
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 37 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dotenv": "^16.4.7",
"express": "^4.21.2",
"http": "^0.0.1-security",
"node-cache": "^5.1.2",
"ws": "^8.18.0"
},
"scripts": {
Expand Down
5 changes: 1 addition & 4 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
require('dotenv').config();
const express = require('express');
const NodeCache = require("node-cache");
const cache = new NodeCache();
const app = express();
const routes = require('./routes.js');

cache.set('restrictedProxy', false);
app.use(routes);
app.set('trust proxy', true);

module.exports = { app, cache };
module.exports = app;
20 changes: 0 additions & 20 deletions src/routes.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
const { Router } = require('express');
const cache = require("./app.js");
const routes = Router();

routes.get('/default', (req, res) => {return res.status(200).json({ message: 'Router route' })});
routes.post('/toggle-restricted-proxy', (req, res) => {
let currentValue = cache.get("restrictedProxy");
if (currentValue === undefined) {
currentValue = false;
cache.set("restrictedProxy", currentValue);
}

const newValue = !currentValue;
cache.set("restrictedProxy", newValue);
console.log({ success: true, restrictedProxy: newValue });

return res.status(200).json({ success: true, restrictedProxy: newValue });
});
routes.get('/restricted-proxy-status', (req, res) => {
const currentValue = cache.get("restrictedProxy");
console.log({ restrictedProxy: currentValue });

return res.status(200).json({ restrictedProxy: currentValue });
});

module.exports = routes;
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ chokidar@^3.5.2:
optionalDependencies:
fsevents "~2.3.2"

[email protected]:
version "2.1.2"
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand Down Expand Up @@ -465,13 +460,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==

node-cache@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/node-cache/-/node-cache-5.1.2.tgz#f264dc2ccad0a780e76253a694e9fd0ed19c398d"
integrity sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==
dependencies:
clone "2.x"

nodemon@^3.1.9:
version "3.1.9"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.1.9.tgz#df502cdc3b120e1c3c0c6e4152349019efa7387b"
Expand Down

0 comments on commit 854c600

Please sign in to comment.