.all((req, res, next) => { const invalidReq = () => { const response = { mensagem: 'Requisição inválida.' }; app.helpers.request(res, false, response, 400); }; if (req.headers.authorization) { let token = req.headers.authorization; if (token.search('Bearer ') === 0) { token = token.replace('Bearer ', ''); if (Guid.isGuid(token)) { next(); } else { const response = { mensagem: 'Não autorizado.' }; app.helpers.request(res, false, response, 401); } } else { invalidReq(); } } else { invalidReq(); } })
record.save(function(e, result) { id = result.id; assert.equal(record.name, result.name); assert.ok(Guid.isGuid(result.id)); assert.ok(result.dateCreated instanceof Date); assert.ok(result.dateModified instanceof Date); Test.get(); });
socket.on('bind', function(token, fn){ if (guid.isGuid(token)){ if (bindings[token]){ fn({ status: 'success', guid: g }); return; } else { fn({ status: 'error' }); } return; } if (!tokens[token]){ fn({ status: 'undefined token' }); } else if (tokens[token].player){ fn({ status: 'unsuccess' }); } else { var g = guid.create().value; fn({ status: 'success', guid: g }); tokens[token].player = socket; bindings[g] = tokens[token]; bindings[g].console.emit('start', {guid: g}); } });
fs.readdirSync('.').forEach((file) => { if (Guid.isGuid(file)) exec(`rm -rf ${file}`) })
function printVersions(versions) { versions.forEach(function (version) { console.log(version.id.substring(0, 8) + ' - ' + version.message + ' (' + version.build + ')'); }); } switch (command) { case 'upload': monploy.upload(process.cwd(), argv, {s3: s3}).done(function (id) { console.log('uploaded ' + id); }); break; case 'download': var id; if (argv.id && Guid.isGuid(argv.id)) { id = argv.id; } else if (argv.id) { argv.id = '' + argv.id; id = monploy.list(argv.name, {s3: s3}).then(function (list) { list = list.filter(function (version) { return version.id.substring(0, argv.id.length) === argv.id; }); if (list.length > 1) { throw new Error('More than one version matches that id'); } else if (list.length < 1) { throw new Error('No versions match that id'); } else { return list[0].id; } });