added sentry to server code
This commit is contained in:
parent
2691dfcf2f
commit
2b4df1cd51
46
package-lock.json
generated
46
package-lock.json
generated
@ -2464,12 +2464,6 @@
|
|||||||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=",
|
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=",
|
||||||
"dev": true
|
"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": {
|
"is-windows": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.1.tgz",
|
||||||
@ -2539,6 +2533,11 @@
|
|||||||
"integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
|
"integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
|
||||||
"dev": true
|
"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": {
|
"json3": {
|
||||||
"version": "3.3.2",
|
"version": "3.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
|
"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",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
|
||||||
"integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew=="
|
"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": {
|
"map-obj": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz",
|
||||||
@ -2871,7 +2875,7 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA=="
|
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM="
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.10",
|
"version": "0.0.10",
|
||||||
@ -3475,6 +3479,23 @@
|
|||||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
|
||||||
"integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
|
"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": {
|
"raven-js": {
|
||||||
"version": "3.16.0",
|
"version": "3.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.16.0.tgz",
|
"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": {
|
"timers-browserify": {
|
||||||
"version": "1.4.2",
|
"version": "1.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz",
|
"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": {
|
"umd": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"helmet": "^3.6.1",
|
"helmet": "^3.6.1",
|
||||||
"jquery": "^3.2.1",
|
"jquery": "^3.2.1",
|
||||||
"mozlog": "^2.1.1",
|
"mozlog": "^2.1.1",
|
||||||
|
"raven": "^2.1.0",
|
||||||
"raven-js": "^3.16.0",
|
"raven-js": "^3.16.0",
|
||||||
"redis": "^2.7.1",
|
"redis": "^2.7.1",
|
||||||
"uglify-es": "3.0.19"
|
"uglify-es": "3.0.19"
|
||||||
|
@ -25,6 +25,11 @@ const conf = convict({
|
|||||||
sentry_id: {
|
sentry_id: {
|
||||||
format: String,
|
format: String,
|
||||||
default: 'https://cdf9a4f43a584f759586af8ceb2194f2@sentry.prod.mozaws.net/238',
|
default: 'https://cdf9a4f43a584f759586af8ceb2194f2@sentry.prod.mozaws.net/238',
|
||||||
|
env: 'P2P_SENTRY_CLIENT'
|
||||||
|
},
|
||||||
|
sentry_dsn: {
|
||||||
|
format: String,
|
||||||
|
default: 'localhost',
|
||||||
env: 'P2P_SENTRY_DSN'
|
env: 'P2P_SENTRY_DSN'
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
@ -39,7 +44,8 @@ conf.validate({ allowed: 'strict' });
|
|||||||
|
|
||||||
const props = conf.getProperties();
|
const props = conf.getProperties();
|
||||||
module.exports = props;
|
module.exports = props;
|
||||||
|
console.log(props.sentry_dsn)
|
||||||
module.exports.notLocalHost =
|
module.exports.notLocalHost =
|
||||||
props.env === 'production' &&
|
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 bytes = require('bytes');
|
||||||
const conf = require('./config.js');
|
const conf = require('./config.js');
|
||||||
const storage = require('./storage.js');
|
const storage = require('./storage.js');
|
||||||
|
const Raven = require('raven');
|
||||||
|
|
||||||
const notLocalHost = conf.notLocalHost;
|
const notLocalHost = conf.notLocalHost;
|
||||||
|
|
||||||
|
if (notLocalHost) {
|
||||||
|
Raven.config(conf.sentry_dsn).install();
|
||||||
|
}
|
||||||
|
|
||||||
const mozlog = require('./log.js');
|
const mozlog = require('./log.js');
|
||||||
|
|
||||||
const log = mozlog('portal.server');
|
const log = mozlog('portal.server');
|
||||||
@ -38,9 +43,9 @@ app.get('/', (req, res) => {
|
|||||||
|
|
||||||
app.get('/exists/:id', (req, res) => {
|
app.get('/exists/:id', (req, res) => {
|
||||||
const id = req.params.id;
|
const id = req.params.id;
|
||||||
storage.exists(id).then(doesExist => {
|
storage.exists(id).then(() => {
|
||||||
res.sendStatus(doesExist ? 200 : 404);
|
res.sendStatus(200);
|
||||||
});
|
}).catch(err => res.sendStatus(404));
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/download/:id', (req, res) => {
|
app.get('/download/:id', (req, res) => {
|
||||||
|
@ -49,7 +49,7 @@ function filename(id) {
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
resolve(reply);
|
resolve(reply);
|
||||||
} else {
|
} else {
|
||||||
reject();
|
reject(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -58,7 +58,7 @@ function filename(id) {
|
|||||||
function exists(id) {
|
function exists(id) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
redis_client.exists(id, (rediserr, reply) => {
|
redis_client.exists(id, (rediserr, reply) => {
|
||||||
resolve(reply === 1);
|
reply === 1 && !rediserr ? resolve() : reject(rediserr);;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user