Merge branch 'master' into heartbeat
This commit is contained in:
commit
72807686f3
6 changed files with 60 additions and 8 deletions
|
@ -25,6 +25,11 @@ const conf = convict({
|
|||
sentry_id: {
|
||||
format: String,
|
||||
default: 'https://cdf9a4f43a584f759586af8ceb2194f2@sentry.prod.mozaws.net/238',
|
||||
env: 'P2P_SENTRY_CLIENT'
|
||||
},
|
||||
sentry_dsn: {
|
||||
format: String,
|
||||
default: 'localhost',
|
||||
env: 'P2P_SENTRY_DSN'
|
||||
},
|
||||
env: {
|
||||
|
@ -42,4 +47,5 @@ module.exports = props;
|
|||
|
||||
module.exports.notLocalHost =
|
||||
props.env === 'production' &&
|
||||
props.s3_bucket !== 'localhost';
|
||||
props.s3_bucket !== 'localhost' &&
|
||||
props.sentry_dsn !== 'localhost';
|
||||
|
|
|
@ -7,9 +7,14 @@ const helmet = require('helmet');
|
|||
const bytes = require('bytes');
|
||||
const conf = require('./config.js');
|
||||
const storage = require('./storage.js');
|
||||
const Raven = require('raven');
|
||||
|
||||
const notLocalHost = conf.notLocalHost;
|
||||
|
||||
if (notLocalHost) {
|
||||
Raven.config(conf.sentry_dsn).install();
|
||||
}
|
||||
|
||||
const mozlog = require('./log.js');
|
||||
|
||||
const log = mozlog('portal.server');
|
||||
|
@ -40,9 +45,9 @@ app.get('/', (req, res) => {
|
|||
|
||||
app.get('/exists/:id', (req, res) => {
|
||||
const id = req.params.id;
|
||||
storage.exists(id).then(doesExist => {
|
||||
res.sendStatus(doesExist ? 200 : 404);
|
||||
});
|
||||
storage.exists(id).then(() => {
|
||||
res.sendStatus(200);
|
||||
}).catch(err => res.sendStatus(404));
|
||||
});
|
||||
|
||||
app.get('/download/:id', (req, res) => {
|
||||
|
|
|
@ -52,7 +52,7 @@ function filename(id) {
|
|||
if (!err) {
|
||||
resolve(reply);
|
||||
} else {
|
||||
reject();
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -61,7 +61,11 @@ function filename(id) {
|
|||
function exists(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
redis_client.exists(id, (rediserr, reply) => {
|
||||
resolve(reply === 1);
|
||||
if (reply === 1 && !rediserr) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(rediserr);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue