Skip to content

Commit c16da47

Browse files
authored
feat: Update all dependencies (#200)
1 parent 2f507c3 commit c16da47

File tree

19 files changed

+14834
-19160
lines changed

19 files changed

+14834
-19160
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
node-version: [14.x, 18.x]
8+
node-version: [20.x, 22.x]
99
steps:
1010
- uses: actions/checkout@v2
1111
- name: Use Node.js ${{ matrix.node-version }}

lib/adapters/amqp.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
const amqpConnectionManager = require('amqp-connection-manager');
2-
const debug = require('debug')('feathers-sync:amqp');
3-
const core = require('../core');
1+
const amqpConnectionManager = require('amqp-connection-manager')
2+
const debug = require('debug')('feathers-sync:amqp')
3+
const core = require('../core')
44

55
module.exports = (config) => {
66
const amqpConnection = amqpConnectionManager.connect(
77
[config.uri],
88
config.amqpConnectionOptions
9-
);
10-
const { deserialize, serialize, key = 'feathersSync' } = config;
11-
debug(`Setting up AMQP connection ${config.uri}`);
9+
)
10+
const { deserialize, serialize, key = 'feathersSync' } = config
11+
debug(`Setting up AMQP connection ${config.uri}`)
1212
return (app) => {
13-
app.configure(core);
13+
app.configure(core)
1414
const channelWrapper = amqpConnection.createChannel({
1515
json: true,
1616
setup: async (channel) => {
1717
try {
1818
// Creates a broadcast channel
19-
await channel.assertExchange(key, 'fanout', { durable: false });
19+
await channel.assertExchange(key, 'fanout', { durable: false })
2020

2121
// Creates a queue and the data will be deleted after delivering being consumed.
2222
const { queue } = await channel.assertQueue('', {
2323
autoDelete: true
24-
});
24+
})
2525
// Binds the exchange broadcast to the queue
26-
await channel.bindQueue(queue, key, 'queue-binding');
26+
await channel.bindQueue(queue, key, 'queue-binding')
2727

2828
// Send the message to the service
2929
channel.consume(
3030
queue,
3131
(message) => {
3232
if (message !== null) {
33-
debug(`Got ${key} event from APMQ channel`);
34-
app.emit('sync-in', message.content);
33+
debug(`Got ${key} event from APMQ channel`)
34+
app.emit('sync-in', message.content)
3535
}
3636
},
3737
{ noAck: true }
38-
);
38+
)
3939
// Publish the received message to the queue
4040
app.on('sync-out', (data) => {
4141
try {
4242
const publishResponse = channel.publish(
4343
key,
4444
queue,
4545
Buffer.from(data)
46-
);
47-
debug(`Publish success: |${publishResponse}| APMQ channel`);
46+
)
47+
debug(`Publish success: |${publishResponse}| APMQ channel`)
4848
} catch (error) {
49-
debug(`Publish fail: |${error.message}| APMQ channel`);
49+
debug(`Publish fail: |${error.message}| APMQ channel`)
5050
}
51-
});
52-
return channel;
51+
})
52+
return channel
5353
} catch (error) {
54-
debug(`Publish fail: |${error.message}| APMQ channel`);
54+
debug(`Publish fail: |${error.message}| APMQ channel`)
5555
}
5656
}
57-
});
57+
})
5858
const ready = new Promise((resolve, reject) => {
5959
channelWrapper.on('close', () => {
60-
reject(new Error('Channel was closed unexpectedly'));
61-
});
60+
reject(new Error('Channel was closed unexpectedly'))
61+
})
6262
channelWrapper.on('connect', () => {
63-
resolve();
64-
});
63+
resolve()
64+
})
6565
channelWrapper.on('error', (error) => {
66-
reject(new Error(error.message));
67-
});
68-
});
66+
reject(new Error(error.message))
67+
})
68+
})
6969
app.sync = {
7070
deserialize,
7171
serialize,
7272
ready,
7373
connection: amqpConnection, // can be useful for tracking amqp connection states
7474
type: 'amqp'
75-
};
76-
};
77-
};
75+
}
76+
}
77+
}

lib/adapters/nats.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const { connect, StringCodec } = require('nats');
2-
const debug = require('debug')('feathers-sync:nats');
3-
const core = require('../core');
1+
const { connect, StringCodec } = require('nats')
2+
const debug = require('debug')('feathers-sync:nats')
3+
const core = require('../core')
44

55
module.exports = (config) => {
6-
debug(`Setting up NATS connection ${config.uri}`);
6+
debug(`Setting up NATS connection ${config.uri}`)
77

88
return (app) => {
99
const {
@@ -12,7 +12,7 @@ module.exports = (config) => {
1212
serialize,
1313
deserialize,
1414
natsConnectionOptions
15-
} = config;
15+
} = config
1616

1717
// Setting up nats connection with unique servers list
1818
const natsClient = connect({
@@ -25,10 +25,10 @@ module.exports = (config) => {
2525
: [])
2626
])
2727
]
28-
});
29-
const stringCodec = StringCodec();
28+
})
29+
const stringCodec = StringCodec()
3030

31-
app.configure(core);
31+
app.configure(core)
3232
app.sync = {
3333
type: 'nats',
3434
serialize,
@@ -40,25 +40,25 @@ module.exports = (config) => {
4040
// listening events and resolving connection
4141
(async () => {
4242
for await (const message of sub) {
43-
const data = stringCodec.decode(message.data);
43+
const data = stringCodec.decode(message.data)
4444
debug(
4545
`[${sub.getProcessed()}]: ${stringCodec.decode(message.data)}`
46-
);
47-
app.emit('sync-in', data);
46+
)
47+
app.emit('sync-in', data)
4848
}
49-
debug('subscription closed');
50-
})();
51-
resolve(connection);
49+
debug('subscription closed')
50+
})()
51+
resolve(connection)
5252
})
53-
.catch((error) => reject(error));
53+
.catch((error) => reject(error))
5454
})
55-
};
55+
}
5656

5757
app.on('sync-out', async (data) => {
58-
const natsClient = await connect(natsConnectionOptions);
59-
debug(`Publishing key ${subject} to NATS`);
60-
await natsClient.publish(subject, stringCodec.encode(data));
61-
await natsClient.drain();
62-
});
63-
};
64-
};
58+
const natsClient = await connect(natsConnectionOptions)
59+
debug(`Publishing key ${subject} to NATS`)
60+
await natsClient.publish(subject, stringCodec.encode(data))
61+
await natsClient.drain()
62+
})
63+
}
64+
}

lib/adapters/redis.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
const redis = require('redis');
2-
const debug = require('debug')('feathers-sync:redis');
3-
const core = require('../core');
1+
const redis = require('redis')
2+
const debug = require('debug')('feathers-sync:redis')
3+
const core = require('../core')
44

55
module.exports = config => {
66
return app => {
7-
const { key, serialize, deserialize, redisClient, uri } = config;
7+
const { key, serialize, deserialize, redisClient, uri } = config
88
const options = {
99
url: uri,
1010
...config.redisOptions
11-
};
11+
}
1212

1313
if (!redisClient) {
14-
debug(`Setting up Redis client for ${options.url}`);
14+
debug(`Setting up Redis client for ${options.url}`)
1515
}
1616

17-
const pub = redisClient || redis.createClient(options);
18-
const sub = pub.duplicate();
17+
const pub = redisClient || redis.createClient(options)
18+
const sub = pub.duplicate()
1919

2020
const msgFromRedisHandler = data => {
21-
debug(`Got ${key} message from Redis`);
22-
app.emit('sync-in', data);
23-
};
21+
debug(`Got ${key} message from Redis`)
22+
app.emit('sync-in', data)
23+
}
2424

25-
app.configure(core);
25+
app.configure(core)
2626
app.sync = {
2727
deserialize,
2828
serialize,
2929
pub,
3030
sub,
3131
type: 'redis',
3232
ready: new Promise((resolve, reject) => {
33-
pub.connect();
34-
sub.connect();
35-
sub.once('ready', resolve);
36-
sub.once('error', reject);
33+
pub.connect()
34+
sub.connect()
35+
sub.once('ready', resolve)
36+
sub.once('error', reject)
3737
}).then(() => sub.subscribe(key, msgFromRedisHandler, true))
38-
};
38+
}
3939

4040
app.on('sync-out', data => {
41-
debug(`Publishing key ${key} to Redis`);
42-
pub.publish(key, data);
43-
});
44-
};
45-
};
41+
debug(`Publishing key ${key} to Redis`)
42+
pub.publish(key, data)
43+
})
44+
}
45+
}

lib/core.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
const debug = require('debug')('feathers-sync');
2-
const feathers = require('@feathersjs/feathers');
3-
const { _ } = require('@feathersjs/commons');
4-
const SYNC = Symbol('feathers-sync/enabled');
1+
const debug = require('debug')('feathers-sync')
2+
const feathers = require('@feathersjs/feathers')
3+
const { _ } = require('@feathersjs/commons')
4+
const SYNC = Symbol('feathers-sync/enabled')
55

6-
const defaultEvents = ['created', 'updated', 'removed', 'patched'];
6+
const defaultEvents = ['created', 'updated', 'removed', 'patched']
77
const getServiceOptions = service => {
88
if (typeof feathers.getServiceOptions === 'function') {
9-
return feathers.getServiceOptions(service);
9+
return feathers.getServiceOptions(service)
1010
}
1111

12-
return {};
13-
};
12+
return {}
13+
}
1414

1515
module.exports = app => {
1616
if (app[SYNC]) {
17-
return;
17+
return
1818
}
1919

20-
app[SYNC] = true;
20+
app[SYNC] = true
2121

2222
if (app.sync) {
23-
throw new Error('Only one type of feathers-sync can be configured on the same application');
23+
throw new Error('Only one type of feathers-sync can be configured on the same application')
2424
}
2525

2626
app.on('sync-in', (rawData) => {
27-
const { event, path, data, context } = app.sync.deserialize(rawData);
28-
const service = app.service(path);
27+
const { event, path, data, context } = app.sync.deserialize(rawData)
28+
const service = app.service(path)
2929
const hook = context
3030
? Object.assign({ app, service }, context)
31-
: context;
31+
: context
3232

3333
if (service) {
34-
debug(`Dispatching sync-in event '${path} ${event}'`);
35-
service._emit(event, data, hook);
34+
debug(`Dispatching sync-in event '${path} ${event}'`)
35+
service._emit(event, data, hook)
3636
} else {
37-
debug(`Invalid sync event '${path} ${event}'`);
37+
debug(`Invalid sync event '${path} ${event}'`)
3838
}
39-
});
39+
})
4040

4141
app.mixins.push((service, path) => {
4242
if (typeof service._emit !== 'function') {
43-
const { events: customEvents = service.events } = getServiceOptions(service);
44-
const events = defaultEvents.concat(customEvents);
43+
const { events: customEvents = service.events } = getServiceOptions(service)
44+
const events = defaultEvents.concat(customEvents)
4545

46-
service._emit = service.emit;
46+
service._emit = service.emit
4747
service.emit = function (event, data, ctx) {
48-
const disabled = ctx && ctx[SYNC] === false;
48+
const disabled = ctx && ctx[SYNC] === false
4949

5050
if (!events.includes(event) || disabled) {
51-
debug(`Passing through non-service event '${path} ${event}'`);
52-
return this._emit(event, data, ctx);
51+
debug(`Passing through non-service event '${path} ${event}'`)
52+
return this._emit(event, data, ctx)
5353
}
5454

55-
const serializedContext = ctx && typeof ctx.toJSON === 'function' ? ctx.toJSON() : ctx;
55+
const serializedContext = ctx && typeof ctx.toJSON === 'function' ? ctx.toJSON() : ctx
5656
const context = ctx && (ctx.app === app || ctx.service === service)
5757
? _.omit(serializedContext, 'app', 'service', 'self')
58-
: serializedContext;
58+
: serializedContext
5959

60-
debug(`Sending sync-out event '${path} ${event}'`);
60+
debug(`Sending sync-out event '${path} ${event}'`)
6161

6262
return app.emit('sync-out', app.sync.serialize({
6363
event, path, data, context
64-
}));
65-
};
64+
}))
65+
}
6666
}
67-
});
68-
};
67+
})
68+
}
6969

70-
module.exports.SYNC = SYNC;
70+
module.exports.SYNC = SYNC

0 commit comments

Comments
 (0)