db.from('capcodes') .del() .where('id', 'in', idList) .then((result) => { res.status(200).send({ 'status': 'ok' }); if (!updateRequired || updateRequired == 0) { nconf.set('database:aliasRefreshRequired', 1); nconf.save(); } }).catch((err) => { res.status(500).send(err); })
const setTokens = () => { let clientId = readlineSync.question('What is your Spotify Client ID? \n', { hideEchoBack: true }); let clientSecret = readlineSync.question('What is your Spotify Client Secret? \n', { hideEchoBack: true }); nconf.set('spotifyClientID', clientId); nconf.set('spotifyClientSecret', clientSecret); nconf.save(); printer.printConfig(); }
async saveToken(token, client, user) { const _token = Object.assign({}, token, { user }, { client }); nconf.set('token', _token); nconf.save(); return _token; }
program .command('reset') .description('reset config back to default settings') .action(() => { nconf.set('spotifyClientID', 'YOUR_SPOTIFY_CLIENT_ID_HERE'); nconf.set('spotifyClientSecret', 'YOUR_SPOTIFY_CLIENT_SECRET_HERE'); nconf.save(); printer.printConfig(); });
db.schema.table('messages', function (table) { table.dropForeign('alias_id') }) .then(function () { return db.schema.table('messages', function (table) { table.dropColumn('alias_id') }) .then(function () { return db.schema.table('messages', function (table) { table.integer('alias_id').unsigned().references('id').inTable('capcodes').onDelete('SET NULL'); }) .then(function () { nconf.set('database:aliasRefreshRequired', 1); nconf.save(); return Promise.resolve() }) }) })
it('should 401 if securemode is enabled and not logged in ', done => { nconf.set('messages:apiSecurity', true); nconf.save(); chai.request(server) .get('/api/messages/5') .end((err, res) => { should.not.exist(err); res.status.should.eql(401); res.type.should.eql('application/json'); nconf.set('messages:apiSecurity', false); done(); }); });
db('messages').update('alias_id', function() { this.select('id') .from('capcodes') .where(db.ref('messages.address'), 'like', db.ref('capcodes.address') ) .orderByRaw("REPLACE(address, '_', '%') DESC LIMIT 1") }) .then((result) => { console.timeEnd('updateMap'); nconf.set('database:aliasRefreshRequired', 0); nconf.save(); logger.main.info('CRON: Alias Refresh Successful') }) .catch((err) => { logger.main.error('CRON: Error refreshing aliases' + err); console.timeEnd('updateMap'); })
it('should return message id 5', done => { nconf.set('messages:HideCapcode', false); nconf.set('messages:HideSource', false); nconf.set('messages:apiSecurity', false); nconf.save(); chai.request(server) .get('/api/messages/5') .end((err, res) => { should.not.exist(err); res.status.should.eql(200); res.type.should.eql('application/json'); res.body.should.be.a('array'); res.body[0].should.have.property('id').eql(5); res.body[0].should.have.property('address').eql('1234570'); res.body[0].should.have .property('message') .eql('This is a Test Message to Address 1234570'); res.body[0].should.have.property('source').eql('Client 4'); done(); }); });
it('should show capcode in hidecapcode mode if logged in ', done => { nconf.set('messages:HideCapcode', true); nconf.save(); passportStub.login({ username: 'useractive', password: 'changeme', }); chai.request(server) .get('/api/messages/5') .end((err, res) => { should.not.exist(err); res.status.should.eql(200); res.type.should.eql('application/json'); res.body.should.be.a('array'); res.body[0].should.have.property('id').eql(5); res.body[0].should.have.property('address').eql('1234570'); res.body[0].should.have .property('message') .eql('This is a Test Message to Address 1234570'); res.body[0].should.have.property('source').eql('Client 4'); nconf.set('messages:HideCapcode', false); done(); }); });
function setUsername(){ let clientUsername = readlineSync.question('What is your Spotify Username? \n'); nconf.set('spotifyUsername', clientUsername); nconf.save(); printer.printConfig(); }
it('should not show capcode in hidecapcode mode if not logged in ', done => { nconf.set('messages:HideCapcode', true); nconf.save(); chai.request(server) .get('/api/messages/5') .end((err, res) => { should.not.exist(err); res.status.should.eql(200); res.type.should.eql('application/json'); res.body.should.be.a('object'); res.body.should.have.property('id').eql(5); res.body.should.not.have.property('address'); res.body.should.have .property('message') .eql('This is a Test Message to Address 1234570'); res.body.should.have.property('source').eql('Client 4'); nconf.set('messages:HideCapcode', false); done(); }); });
it('should not show capcode in hidecapcode mode if not logged in ', done => { nconf.set('messages:HideCapcode', true); nconf.save(); chai.request(server) .get('/api/messages') .end((err, res) => { should.not.exist(err); res.status.should.eql(200); res.type.should.eql('application/json'); res.body.should.be.a('object'); res.body.messages[0].should.have.property('id').eql(4); res.body.messages[0].should.not.have.property('address').eql('1234569'); res.body.messages[0].should.have .property('message') .eql('This is a Test Message to Address 1234569'); res.body.messages[0].should.have.property('source').eql('Client 3'); nconf.set('messages:HideCapcode', false); done(); }); });
it('should 401 if securemode is enabled and not logged in ', done => { nconf.set('messages:apiSecurity', true); nconf.save(); chai.request(server) .get('/api/messages') .end((err, res) => { should.not.exist(err); res.status.should.eql(401); res.type.should.eql('application/json'); nconf.set('messages:apiSecurity', false); nconf.save(); done(); }); });
async saveToken(token, client, user) { const _token = Object.assign({}, token, { user }, { client }); nconf.set('token', _token); nconf.save(); return _token; }
db.from('capcodes') .del() .where('id', id) .then((result) => { res.status(200).send({ 'status': 'ok' }); if (!updateRequired || updateRequired == 0) { nconf.set('database:aliasRefreshRequired', 1); nconf.save(); } }) .catch((err) => { res.status(500).send(err); })