Skip to content

Commit

Permalink
moved node-cache init to server.js
Browse files Browse the repository at this point in the history
  • Loading branch information
litsel-pitdyr committed Jan 6, 2025
1 parent f09bc99 commit 55aedd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ require('dotenv').config();
const app = require("./src/app.js");
const http = require("http");
const WebSocket = require('ws');
const NodeCache = require("node-cache");
const cache = new NodeCache();

const port = 8080;
const host = '127.0.0.1';
Expand All @@ -20,6 +22,9 @@ function tsError(...args) {
console.error(`[${new Date().toISOString()}]`, ...args);
}

cache.set('restrictedProxy', false);
app.set('cache', cache);

// Read the remote WebSocket URL from environment variables
const REMOTE_URL = process.env.REMOTE_URL || 'wss://echo.websocket.org';

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;

0 comments on commit 55aedd5

Please sign in to comment.