Skip to content

Commit 189ee9a

Browse files
authored
Merge pull request #14 from rsscloud/update-packages-and-modernize
Upgrade packages and modernize JavaScript for Node.js 22
2 parents 1c74086 + cd68fc6 commit 189ee9a

34 files changed

+3249
-4004
lines changed

.eslintrc.json

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

.prettierignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dependencies
2+
node_modules/
3+
package-lock.json
4+
5+
# Build output
6+
dist/
7+
build/
8+
9+
# Third-party libraries
10+
public/js/
11+
12+
# Logs
13+
*.log
14+
15+
# Database
16+
data/
17+
18+
# Docker
19+
Dockerfile
20+
docker-compose.yml
21+
22+
# Documentation that should preserve formatting
23+
DEVNOTES.md

.prettierrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"tabWidth": 4,
3+
"useTabs": false,
4+
"semi": true,
5+
"singleQuote": false,
6+
"quoteProps": "as-needed",
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"bracketSameLine": false,
10+
"arrowParens": "avoid",
11+
"printWidth": 80,
12+
"endOfLine": "lf"
13+
}

CLAUDE.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,61 @@ This is an rssCloud Server v2 implementation in Node.js - a notification protoco
99
## Development Commands
1010

1111
### Start Development
12+
1213
- `npm start` - Start server with nodemon (auto-reload on changes)
1314
- `npm run client` - Start client with nodemon
1415

1516
### Testing & Quality
16-
- `npm test` - Run Mocha test suite
17+
18+
- `npm test` - Run Mocha test suite (called by test-api)
1719
- `npm run test-api` - Run full API tests using Docker containers (MacOS tested)
1820
- `npm run jshint` - Run JSHint linter
1921
- `npm run eslint` - Run ESLint with auto-fix on controllers/, services/, test/
2022

2123
### Data Management
24+
2225
- `npm run import-data` - Import data using bin/import-data.js
2326

2427
## Architecture
2528

2629
### Core Application Structure
30+
2731
- **app.js** - Main Express application entry point, sets up middleware, MongoDB connection, and starts server
2832
- **config.js** - Configuration management using nconf (env vars, CLI args, defaults)
2933
- **controllers/** - Express route handlers for API endpoints
3034
- **services/** - Business logic modules for core functionality
3135
- **views/** - Handlebars templates for web interface
3236

3337
### Key Services
38+
3439
- **services/mongodb.js** - MongoDB connection management with graceful shutdown
35-
- **services/notify-*.js** - Notification system for subscribers
40+
- **services/notify-\*.js** - Notification system for subscribers
3641
- **services/ping.js** - RSS feed update detection and processing
3742
- **services/please-notify.js** - Subscription management
3843

3944
### API Endpoints (defined in controllers/index.js)
45+
4046
- `/pleaseNotify` - Subscribe to RSS feed notifications
4147
- `/ping` - Notify server of RSS feed updates
4248
- `/viewLog` - Event log viewer for debugging
4349
- `/RPC2` - XML-RPC endpoint
4450
- Web forms available at `/pleaseNotifyForm` and `/pingForm`
4551

4652
### Configuration
53+
4754
Environment variables (with defaults in config.js):
55+
4856
- `MONGODB_URI` (default: mongodb://localhost:27017/rsscloud)
4957
- `DOMAIN` (default: localhost)
5058
- `PORT` (default: 5337)
5159
- Resource limits: MAX_RESOURCE_SIZE, REQUEST_TIMEOUT, etc.
5260

5361
### Database
62+
5463
Uses MongoDB for storing subscriptions and resource state. Connection handled through services/mongodb.js with proper cleanup on shutdown.
5564

5665
### Testing
66+
5767
- Unit tests in test/ directory using Mocha/Chai
5868
- Docker-based API testing with mock endpoints
59-
- Test fixtures and SSL certificates in test/keys/
69+
- Test fixtures and SSL certificates in test/keys/

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:14 AS base
1+
FROM node:22 AS base
22

33
# Dockerize is needed to sync containers startup
44
ENV DOCKERIZE_VERSION v0.6.1

app.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,26 @@ const config = require('./config'),
44
cors = require('cors'),
55
express = require('express'),
66
exphbs = require('express-handlebars'),
7-
fs = require('fs'),
87
moment = require('moment'),
98
mongodb = require('./services/mongodb'),
10-
morgan = require('morgan'),
11-
removeExpiredSubscriptions = require('./services/remove-expired-subscriptions');
9+
morgan = require('morgan');
10+
// removeExpiredSubscriptions = require('./services/remove-expired-subscriptions');
1211

13-
let app,
14-
expressWs,
15-
hbs,
16-
server;
12+
let app, hbs, server;
1713

1814
require('console-stamp')(console, 'HH:MM:ss.l');
1915

2016
console.log(`${config.appName} ${config.appVersion}`);
2117

2218
// TODO: Every 24 hours run removeExpiredSubscriptions(data);
2319

24-
morgan.format('mydate', function() {
25-
var df = require('dateformat');
20+
morgan.format('mydate', () => {
21+
const df = require('dateformat');
2622
return df(new Date(), 'HH:MM:ss.l');
2723
});
2824

2925
app = express();
30-
expressWs = require('express-ws')(app);
26+
require('express-ws')(app);
3127

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

@@ -36,7 +32,7 @@ app.use(cors());
3632
// Configure handlebars template engine to work with moment
3733
hbs = exphbs.create({
3834
helpers: {
39-
formatDate: function (datetime, format) {
35+
formatDate: (datetime, format) => {
4036
return moment(datetime).format(format);
4137
}
4238
}
@@ -58,17 +54,17 @@ app.use(require('./controllers'));
5854
// Start server
5955
mongodb.connect('rsscloud', config.mongodbUri)
6056
.then(() => {
61-
server = app.listen(config.port, function () {
57+
server = app.listen(config.port, () => {
6258
app.locals.host = config.domain;
6359
app.locals.port = server.address().port;
6460

6561
if (app.locals.host.indexOf(':') > -1) {
6662
app.locals.host = '[' + app.locals.host + ']';
6763
}
6864

69-
console.log('Listening at http://%s:%s', app.locals.host, app.locals.port);
65+
console.log(`Listening at http://${app.locals.host}:${app.locals.port}`);
7066
})
71-
.on('error', function (error) {
67+
.on('error', (error) => {
7268
switch (error.code) {
7369
case 'EADDRINUSE':
7470
console.log(`Error: Port ${config.port} is already in use.`);

client.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var app,
2-
bodyParser = require('body-parser'),
1+
const bodyParser = require('body-parser'),
32
express = require('express'),
43
morgan = require('morgan'),
54
nconf = require('nconf'),
65
packageJson = require('./package.json'),
7-
server,
86
textParser = bodyParser.text({ type: '*/xml'}),
97
urlencodedParser = bodyParser.urlencoded({ extended: false });
108

9+
let app, server;
10+
1111
require('console-stamp')(console, 'HH:MM:ss.l');
1212

1313
// Setup nconf to use (in-order):
@@ -28,10 +28,10 @@ nconf
2828
"PORT": 9000
2929
});
3030

31-
console.log(nconf.get('APP_NAME') + ' ' + nconf.get('APP_VERSION'));
31+
console.log(`${nconf.get('APP_NAME')} ${nconf.get('APP_VERSION')}`);
3232

33-
morgan.format('mydate', function() {
34-
var df = require('dateformat');
33+
morgan.format('mydate', () => {
34+
const df = require('dateformat');
3535
return df(new Date(), 'HH:MM:ss.l');
3636
});
3737

@@ -44,35 +44,35 @@ app.use(express.static('public', {
4444
maxAge: '1d'
4545
}));
4646

47-
app.post('/RPC2', textParser, function (req, res) {
47+
app.post('/RPC2', textParser, (req, res) => {
4848
console.log('rpc');
4949
console.dir(req.body);
5050
res.send('');
51-
})
51+
});
5252

53-
app.get('/*', function (req, res) {
54-
var challenge = req.query.challenge || "";
53+
app.get('/*', (req, res) => {
54+
const challenge = req.query.challenge || "";
5555
console.log('get');
5656
console.dir(req.query);
5757
res.send(challenge);
5858
});
5959

60-
app.post('/*', urlencodedParser, function (req, res) {
60+
app.post('/*', urlencodedParser, (req, res) => {
6161
console.log('post');
6262
console.dir(req.body);
6363
res.send('');
6464
});
6565

66-
server = app.listen(nconf.get('PORT'), function () {
67-
var host = nconf.get('DOMAIN'),
66+
server = app.listen(nconf.get('PORT'), () => {
67+
const host = nconf.get('DOMAIN'),
6868
port = server.address().port;
6969

70-
console.log('Listening at http://%s:%s', host, port);
70+
console.log(`Listening at http://${host}:${port}`);
7171
})
72-
.on('error', function (error) {
72+
.on('error', (error) => {
7373
switch (error.code) {
7474
case 'EADDRINUSE':
75-
console.log('Error: Port ' + nconf.get('PORT') + ' is already in use.');
75+
console.log(`Error: Port ${nconf.get('PORT')} is already in use.`);
7676
break;
7777
default:
7878
console.log(error.code);

controllers/docs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ const express = require('express'),
33
md = require('markdown-it')(),
44
fs = require('fs');
55

6-
router.get('/', function (req, res) {
6+
router.get('/', (req, res) => {
77
switch (req.accepts('html')) {
8-
case 'html':
8+
case 'html': {
99
const vals = {
1010
htmltext: md.render(fs.readFileSync('README.md', { encoding: 'utf8' }))
1111
};
1212
res.render('docs', vals);
1313
break;
14+
}
1415
default:
1516
res.status(406).send('Not Acceptable');
1617
break;

controllers/home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const express = require('express'),
22
router = new express.Router();
33

4-
router.get('/', function (req, res) {
4+
router.get('/', function(req, res) {
55
switch (req.accepts('html')) {
66
case 'html':
77
res.render('home');

controllers/ping-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const express = require('express'),
22
router = new express.Router();
33

4-
router.get('/', function (req, res) {
4+
router.get('/', function(req, res) {
55
switch (req.accepts('html')) {
66
case 'html':
77
res.render('ping-form');

0 commit comments

Comments
 (0)