added sentry to server code
This commit is contained in:
parent
2691dfcf2f
commit
2b4df1cd51
5 changed files with 52 additions and 20 deletions
46
package-lock.json
generated
46
package-lock.json
generated
|
@ -2464,12 +2464,6 @@
|
|||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-windows": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.1.tgz",
|
||||
|
@ -2539,6 +2533,11 @@
|
|||
"integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
|
||||
"dev": true
|
||||
},
|
||||
"json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
|
||||
},
|
||||
"json3": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
|
||||
|
@ -2771,6 +2770,11 @@
|
|||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
|
||||
"integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew=="
|
||||
},
|
||||
"lsmod": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lsmod/-/lsmod-1.0.0.tgz",
|
||||
"integrity": "sha1-mgD3bco26yP6BTUK/htYXUKZ5ks="
|
||||
},
|
||||
"map-obj": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz",
|
||||
|
@ -2871,7 +2875,7 @@
|
|||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA=="
|
||||
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM="
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.10",
|
||||
|
@ -3475,6 +3479,23 @@
|
|||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
|
||||
"integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
|
||||
},
|
||||
"raven": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/raven/-/raven-2.1.0.tgz",
|
||||
"integrity": "sha1-G2JOVjdNnJ2Tx0RIRhoqNWzjdSc=",
|
||||
"dependencies": {
|
||||
"stack-trace": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz",
|
||||
"integrity": "sha1-qPbq7KkGdMMz58Q5U/J1tFFRBpU="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.0.tgz",
|
||||
"integrity": "sha1-Zyj8BFnEUNeWqZwxg3VpvfZy1yg="
|
||||
}
|
||||
}
|
||||
},
|
||||
"raven-js": {
|
||||
"version": "3.16.0",
|
||||
"resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.16.0.tgz",
|
||||
|
@ -4232,6 +4253,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"timed-out": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
|
||||
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8="
|
||||
},
|
||||
"timers-browserify": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz",
|
||||
|
@ -4303,12 +4329,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"uglify-to-browserify": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
|
||||
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
|
||||
"optional": true
|
||||
},
|
||||
"umd": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz",
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"helmet": "^3.6.1",
|
||||
"jquery": "^3.2.1",
|
||||
"mozlog": "^2.1.1",
|
||||
"raven": "^2.1.0",
|
||||
"raven-js": "^3.16.0",
|
||||
"redis": "^2.7.1",
|
||||
"uglify-es": "3.0.19"
|
||||
|
|
|
@ -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: {
|
||||
|
@ -39,7 +44,8 @@ conf.validate({ allowed: 'strict' });
|
|||
|
||||
const props = conf.getProperties();
|
||||
module.exports = props;
|
||||
|
||||
console.log(props.sentry_dsn)
|
||||
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');
|
||||
|
@ -38,9 +43,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) => {
|
||||
|
|
|
@ -49,7 +49,7 @@ function filename(id) {
|
|||
if (!err) {
|
||||
resolve(reply);
|
||||
} else {
|
||||
reject();
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ function filename(id) {
|
|||
function exists(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
redis_client.exists(id, (rediserr, reply) => {
|
||||
resolve(reply === 1);
|
||||
reply === 1 && !rediserr ? resolve() : reject(rediserr);;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue