Skip to content

Commit

Permalink
bin: add u-wave-announce by default (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop authored Feb 28, 2021
1 parent 2f7c243 commit a7af87a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
7 changes: 7 additions & 0 deletions bin/u-wave-core
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Ajv = require('ajv').default;
const addFormats = require('ajv-formats').default;
const ytSource = require('u-wave-source-youtube');
const scSource = require('u-wave-source-soundcloud');
const announce = require('u-wave-announce');
const uwave = require('..');
const pkg = require('../package.json');
const argv = require('minimist')(process.argv.slice(2));
Expand Down Expand Up @@ -70,6 +71,10 @@ if (argv.h || argv.help || !validConfig) {
console.log(' URL of the Redis instance to connect to. Defaults to redis://localhost:6379/.');
console.log(' MONGODB_URL');
console.log(' URL of the MongoDB database to use. Defaults to mongodb://localhost:27017/uwave.');
console.log(' YOUTUBE_API_KEY [optional]');
console.log(' Your YouTube Data API key.');
console.log(' SOUNDCLOUD_API_KEY [optional]');
console.log(' Your SoundCloud API key.');
console.log();
}

Expand Down Expand Up @@ -109,6 +114,8 @@ uw.on('redisError', (err) => {
throw explain(err, 'Could not connect to the Redis server. Is it installed and running?');
});

uw.use(announce);

if (config.YOUTUBE_API_KEY) {
uw.source(ytSource, {
key: config.YOUTUBE_API_KEY,
Expand Down
10 changes: 4 additions & 6 deletions dev/u-wave-dev-server
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ async function start() {
throw explain(err, 'Could not connect to the Redis server. Is it installed and running?');
});

if (process.env.HUB_URL) {
uw.use(announce, {
// Generate a random one in a real app!
seed: Buffer.from('8286a5e55c62d93a042b8c56c8face52c05354c288807d941751f0e9060c2ded', 'hex'),
});
}
uw.use(announce, {
// Omit this in a real app: it will auto-generate one for you.
seed: Buffer.from('8286a5e55c62d93a042b8c56c8face52c05354c288807d941751f0e9060c2ded', 'hex'),
});

uw.use(async (uw) => {
if (process.env.YOUTUBE_API_KEY) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"router": "^1.3.3",
"secure-json-parse": "^2.1.0",
"transliteration": "^2.1.11",
"u-wave-announce": "^0.5.1",
"u-wave-source-soundcloud": "^2.0.0",
"u-wave-source-youtube": "^1.3.0",
"ultron": "^1.1.1",
Expand All @@ -74,8 +75,7 @@
"nodemon": "^2.0.2",
"recaptcha-test-keys": "^1.0.0",
"sinon": "^9.0.0",
"supertest": "^6.1.3",
"u-wave-announce": "^0.4.0"
"supertest": "^6.1.3"
},
"scripts": {
"test:mocha": "mocha --exit",
Expand Down
1 change: 1 addition & 0 deletions src/plugins/configStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class ConfigStore {
if (!validate) return undefined;

const config = (await this.load(key)) || {};
// Allowed to fail--just fills in defaults
validate(config);

return config;
Expand Down

0 comments on commit a7af87a

Please sign in to comment.