Skip to content

Commit 8a6a0e1

Browse files
andrewshellclaude
andcommitted
Remove unused dependencies and simplify frontend
## Dependencies Removed: - eslint-config-crockford (already replaced with flat config) - sprintf-js (replaced with template literals in app-messages) - console-stamp (removed console wrapper, use plain console methods) - nconf (replaced with simple environment variable configuration) - express-ws (removed websocket functionality) ## Frontend Simplification: - Removed Bootstrap CSS/JS, FontAwesome, jQuery, Handlebars client-side - Removed all heavy dependencies from public/ folder - Created simple, clean CSS for basic styling - Removed websocket live updates from log viewer - Removed modals and displayed headers inline for better scanning - Updated all views to use semantic HTML with minimal CSS - Added server-side date formatting using existing dayjs integration - Maintained all functionality except live websocket updates ## Results: - Faster page loads and cleaner codebase - No client-side JavaScript dependencies - Mobile-friendly responsive design - Easy-to-scan log display with inline headers - Maintained backward compatibility with environment variables 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent bd2b763 commit 8a6a0e1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+375
-8396
lines changed

app.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const config = require('./config'),
1212

1313
let app, hbs, server, dayjs;
1414

15-
require('console-stamp')(console, 'HH:MM:ss.l');
16-
1715
console.log(`${config.appName} ${config.appVersion}`);
1816

1917
// Schedule cleanup tasks
@@ -39,7 +37,6 @@ async function initializeDayjs() {
3937
}
4038

4139
app = express();
42-
require('express-ws')(app);
4340

4441
app.use(morgan('[:mydate] :method :url :status :res[content-length] - :remote-addr - :response-time ms'));
4542

client.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
const bodyParser = require('body-parser'),
22
express = require('express'),
33
morgan = require('morgan'),
4-
nconf = require('nconf'),
54
packageJson = require('./package.json'),
65
textParser = bodyParser.text({ type: '*/xml'}),
76
urlencodedParser = bodyParser.urlencoded({ extended: false });
87

9-
let app, server;
8+
// Simple config utility
9+
function getConfig(key, defaultValue) {
10+
return process.env[key] ?? defaultValue;
11+
}
1012

11-
require('console-stamp')(console, 'HH:MM:ss.l');
13+
function getNumericConfig(key, defaultValue) {
14+
const value = process.env[key];
15+
return value ? parseInt(value, 10) : defaultValue;
16+
}
1217

13-
// Setup nconf to use (in-order):
14-
// 1. Overrides
15-
// 2. Command-line arguments
16-
// 3. Environment variables
17-
// 4. A config.json file
18-
// 5. Default values
19-
nconf
20-
.overrides({
21-
'APP_NAME': 'rssCloudClient',
22-
'APP_VERSION': packageJson.version
23-
})
24-
.argv()
25-
.env()
26-
.defaults({
27-
'DOMAIN': 'localhost',
28-
'PORT': 9000
29-
});
18+
const clientConfig = {
19+
appName: 'rssCloudClient',
20+
appVersion: packageJson.version,
21+
domain: getConfig('DOMAIN', 'localhost'),
22+
port: getNumericConfig('PORT', 9000)
23+
};
24+
25+
let app, server;
3026

31-
console.log(`${nconf.get('APP_NAME')} ${nconf.get('APP_VERSION')}`);
27+
console.log(`${clientConfig.appName} ${clientConfig.appVersion}`);
3228

3329
morgan.format('mydate', () => {
3430
return new Date().toLocaleTimeString('en-US', { hour12: false, fractionalSecondDigits: 3 }).replace(/:/g, ':');
@@ -56,16 +52,16 @@ app.post('/*', urlencodedParser, (req, res) => {
5652
res.send('');
5753
});
5854

59-
server = app.listen(nconf.get('PORT'), () => {
60-
const host = nconf.get('DOMAIN'),
55+
server = app.listen(clientConfig.port, () => {
56+
const host = clientConfig.domain,
6157
port = server.address().port;
6258

6359
console.log(`Listening at http://${host}:${port}`);
6460
})
6561
.on('error', (error) => {
6662
switch (error.code) {
6763
case 'EADDRINUSE':
68-
console.log(`Error: Port ${nconf.get('PORT')} is already in use.`);
64+
console.log(`Error: Port ${clientConfig.port} is already in use.`);
6965
break;
7066
default:
7167
console.log(error.code);

config.js

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
1-
const nconf = require('nconf'),
2-
packageJson = require('./package.json');
1+
const packageJson = require('./package.json');
32

4-
// Setup nconf to use (in-order):
5-
// 1. Overrides
6-
// 2. Command-line arguments
7-
// 3. Environment variables
8-
// 4. Default values
9-
nconf
10-
.overrides({
11-
'APP_NAME': 'rssCloudServer',
12-
'APP_VERSION': packageJson.version
13-
})
14-
.argv()
15-
.env()
16-
.defaults({
17-
'DOMAIN': 'localhost',
18-
'PORT': 5337,
19-
'MONGODB_URI': 'mongodb://localhost:27017/rsscloud',
20-
'MAX_CONSECUTIVE_ERRORS': 3,
21-
'MAX_RESOURCE_SIZE': 256000,
22-
'CT_SECS_RESOURCE_EXPIRE': 90000,
23-
'MIN_SECS_BETWEEN_PINGS': 0,
24-
'REQUEST_TIMEOUT': 4000,
25-
'LOG_RETENTION_HOURS': 2
26-
});
3+
// Simple config utility that reads from process.env with defaults
4+
function getConfig(key, defaultValue) {
5+
return process.env[key] ?? defaultValue;
6+
}
7+
8+
// Parse numeric values
9+
function getNumericConfig(key, defaultValue) {
10+
const value = process.env[key];
11+
return value ? parseInt(value, 10) : defaultValue;
12+
}
2713

2814
module.exports = {
29-
appName: nconf.get('APP_NAME'),
30-
appVersion: nconf.get('APP_VERSION'),
31-
domain: nconf.get('DOMAIN'),
32-
port: nconf.get('PORT'),
33-
mongodbUri: nconf.get('MONGODB_URI'),
34-
maxConsecutiveErrors: nconf.get('MAX_CONSECUTIVE_ERRORS'),
35-
maxResourceSize: nconf.get('MAX_RESOURCE_SIZE'),
36-
ctSecsResourceExpire: nconf.get('CT_SECS_RESOURCE_EXPIRE'),
37-
minSecsBetweenPings: nconf.get('MIN_SECS_BETWEEN_PINGS'),
38-
requestTimeout: nconf.get('REQUEST_TIMEOUT'),
39-
logRetentionHours: nconf.get('LOG_RETENTION_HOURS')
15+
appName: 'rssCloudServer',
16+
appVersion: packageJson.version,
17+
domain: getConfig('DOMAIN', 'localhost'),
18+
port: getNumericConfig('PORT', 5337),
19+
mongodbUri: getConfig('MONGODB_URI', 'mongodb://localhost:27017/rsscloud'),
20+
maxConsecutiveErrors: getNumericConfig('MAX_CONSECUTIVE_ERRORS', 3),
21+
maxResourceSize: getNumericConfig('MAX_RESOURCE_SIZE', 256000),
22+
ctSecsResourceExpire: getNumericConfig('CT_SECS_RESOURCE_EXPIRE', 90000),
23+
minSecsBetweenPings: getNumericConfig('MIN_SECS_BETWEEN_PINGS', 0),
24+
requestTimeout: getNumericConfig('REQUEST_TIMEOUT', 4000),
25+
logRetentionHours: getNumericConfig('LOG_RETENTION_HOURS', 2)
4026
};

controllers/view-log.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
const ErrorResponse = require('../services/error-response'),
33
errorResult = require('../services/error-result'),
44
express = require('express'),
5-
logEmitter = require('../services/log-emitter'),
5+
getDayjs = require('../services/dayjs-wrapper'),
66
mongodb = require('../services/mongodb'),
77
router = new express.Router();
88

9-
require('express-ws')(router);
10-
119
async function fetchVals(_db, _callback) {
10+
const dayjs = await getDayjs();
1211
const vals = {
1312
'eventlog': []
1413
},
@@ -26,6 +25,9 @@ async function fetchVals(_db, _callback) {
2625

2726
item.headers = JSON.parse(item.headers);
2827

28+
// Format time for display (hour:minute AM/PM)
29+
item.time = dayjs(item.time).format('h:mmA');
30+
2931
return item;
3032
});
3133

@@ -35,7 +37,6 @@ async function fetchVals(_db, _callback) {
3537
function processResponse(req, res, vals) {
3638
switch (req.accepts('html', 'json')) {
3739
case 'html':
38-
vals.wshost = res.app.locals.host + ':' + res.app.locals.port;
3940
res.render('view-log', vals);
4041
break;
4142
case 'json':
@@ -60,16 +61,4 @@ router.get('/', function(req, res) {
6061
.catch(err => handleError(req, res, err));
6162
});
6263

63-
router.ws('/', (ws, _req) => {
64-
function sendLogEvent(logEvent) {
65-
ws.send(logEvent);
66-
}
67-
68-
logEmitter.on('logged-event', sendLogEvent);
69-
70-
ws.on('close', function() {
71-
logEmitter.removeListener('logged-event', sendLogEvent);
72-
});
73-
});
74-
7564
module.exports = router;

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@
1919
"license": "MIT",
2020
"dependencies": {
2121
"body-parser": "^2.2.0",
22-
"console-stamp": "^3.1.2",
2322
"cors": "^2.8.5",
2423
"dotenv": "^16.5.0",
2524
"express": "^4.21.2",
2625
"express-handlebars": "^5.3.3",
27-
"express-ws": "^5.0.2",
2826
"markdown-it": "^14.1.0",
2927
"dayjs": "^1.11.13",
3028
"mongodb": "6.17.0",
3129
"morgan": "^1.10.0",
32-
"nconf": "^0.13.0",
33-
"sprintf-js": "^1.1.3",
3430
"xml2js": "^0.6.2",
3531
"xmlbuilder": "^15.1.1"
3632
},
@@ -44,7 +40,6 @@
4440
"chai-json": "^1.0.0",
4541
"chai-xml": "^0.4.1",
4642
"eslint": "^9.29.0",
47-
"eslint-config-crockford": "^2.0.0",
4843
"https": "^1.0.0",
4944
"mocha": "^11.7.1",
5045
"mocha-multi": "^1.1.7",

public/css/bootstrap.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

public/css/bootstrap.min.css

Lines changed: 0 additions & 5 deletions
This file was deleted.

public/css/font-awesome.min.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)