kopia lustrzana https://github.com/badgen/badgen.net
rodzic
949b65f838
commit
75f7b67957
|
@ -1,4 +1,3 @@
|
|||
const raven = require('./raven.js')
|
||||
const sendStats = require('./send-stats.js')
|
||||
|
||||
module.exports = async (service, fn, paramsPath) => {
|
||||
|
@ -34,7 +33,6 @@ const gotErrorHandler = (service, paramsPath, err) => {
|
|||
}
|
||||
|
||||
logError(serviceKey, status, err)
|
||||
sendError(serviceKey, status, err)
|
||||
sendStats('error', status, serviceKey)
|
||||
|
||||
return { status, failed: true }
|
||||
|
@ -49,15 +47,3 @@ const logError = (serviceKey, status, err) => {
|
|||
console.error(` @ ${err.url} [${err.statusCode || err.code || err.message}]`)
|
||||
}
|
||||
}
|
||||
|
||||
// send error to sentry
|
||||
const sendError = (serviceKey, status, err) => {
|
||||
if (status !== 'unknown') return
|
||||
|
||||
raven && raven.captureException(err, {
|
||||
tags: {
|
||||
serviceKey,
|
||||
url: err.url
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
const raven = require('raven')
|
||||
const { SENTRY_URI } = process.env
|
||||
|
||||
if (SENTRY_URI) {
|
||||
raven.config(SENTRY_URI).install()
|
||||
}
|
||||
|
||||
module.exports = SENTRY_URI && raven
|
10
service.js
10
service.js
|
@ -7,7 +7,6 @@ const serveBadge = require('./libs/serve-badge.js')
|
|||
const serveMetadata = require('./libs/serve-metadata.js')
|
||||
const liveHandlers = require('./libs/live-handlers.js')
|
||||
const serveApi = require('./libs/serve-api.js')
|
||||
const raven = require('./libs/raven.js')
|
||||
|
||||
const indexHandler = (req, res) => {
|
||||
if (req.headers.host === 'badgen.now.sh') {
|
||||
|
@ -42,10 +41,7 @@ module.exports = (req, res) => {
|
|||
}
|
||||
}
|
||||
|
||||
const autoRun = () => {
|
||||
if (require.main === module) {
|
||||
micro(module.exports).listen(3000)
|
||||
}
|
||||
// auto run
|
||||
if (require.main === module) {
|
||||
micro(module.exports).listen(3000)
|
||||
}
|
||||
|
||||
raven ? raven.context(autoRun) : autoRun()
|
||||
|
|
Ładowanie…
Reference in New Issue