Skip to content

Commit abac9f1

Browse files
committed
chore: satisfy standard
1 parent 91c6426 commit abac9f1

18 files changed

+1192
-1192
lines changed

lib/deprecate-node-event.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ module.exports.attributes = {
88
name: 'deprecateNode'
99
}
1010

11-
function deprecateNodeEvent (server, {env, channel}, next) {
11+
function deprecateNodeEvent (server, { env, channel }, next) {
1212
server.route({
1313
method: 'POST',
1414
path: '/deprecate-node',
1515
config: {
16-
pre: [{method: (request, reply) => {
16+
pre: [{ method: (request, reply) => {
1717
if (request.headers['bearer-token'] === env.BEARER_TOKEN) {
1818
return reply.continue()
1919
}
2020
return reply(Boom.unauthorized())
21-
}}]
21+
} }]
2222
},
2323
handler
2424
})
2525

2626
async function handler (request, reply) {
27-
if (!_.get(request, 'payload.repositoryFullName')) return reply({error: 'repositoryFullName missing'}).code(400)
28-
if (!_.get(request, 'payload.nodeVersion')) return reply({error: 'nodeVersion missing'}).code(400)
29-
if (!_.get(request, 'payload.codeName')) return reply({error: 'codeName missing'}).code(400)
30-
if (!_.get(request, 'payload.newLowestVersion')) return reply({error: 'newLowestVersion missing'}).code(400)
31-
if (!_.get(request, 'payload.newLowestCodeName')) return reply({error: 'newLowestCodeName missing'}).code(400)
27+
if (!_.get(request, 'payload.repositoryFullName')) return reply({ error: 'repositoryFullName missing' }).code(400)
28+
if (!_.get(request, 'payload.nodeVersion')) return reply({ error: 'nodeVersion missing' }).code(400)
29+
if (!_.get(request, 'payload.codeName')) return reply({ error: 'codeName missing' }).code(400)
30+
if (!_.get(request, 'payload.newLowestVersion')) return reply({ error: 'newLowestVersion missing' }).code(400)
31+
if (!_.get(request, 'payload.newLowestCodeName')) return reply({ error: 'newLowestCodeName missing' }).code(400)
3232
// `request.payload.announcementURL` is optional
3333

3434
const job = {
@@ -42,7 +42,7 @@ function deprecateNodeEvent (server, {env, channel}, next) {
4242
}
4343

4444
try {
45-
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), {priority: 3})
45+
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), { priority: 3 })
4646
} catch (err) {
4747
rollbar.error(err, _.assign({}, request.raw.req, {
4848
socket: {
@@ -52,10 +52,10 @@ function deprecateNodeEvent (server, {env, channel}, next) {
5252
remoteAddress: request.info.remoteAddress
5353
}
5454
}))
55-
return reply({error: true}).code(500)
55+
return reply({ error: true }).code(500)
5656
}
5757

58-
reply({ok: true}).code(202)
58+
reply({ ok: true }).code(202)
5959
}
6060

6161
next()

lib/env.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
const envalid = require('envalid')
2-
const {str, num, url, bool} = envalid
2+
const { str, num, url, bool } = envalid
33

44
module.exports = envalid.cleanEnv(process.env, {
5-
PORT: num({default: 5000}),
6-
WEBHOOKS_SECRET: str({devDefault: 'YOLO'}),
7-
NPMHOOKS_SECRET: str({devDefault: 'SWAG'}),
8-
QUEUE_NAME: str({default: 'events'}),
9-
AMQP_URL: url({devDefault: 'amqp://localhost?heartbeat=15'}),
10-
NODE_ENV: str({choices: ['development', 'staging', 'production'], devDefault: 'development'}),
11-
ROLLBAR_TOKEN_HOOKS: str({devDefault: ''}),
12-
STATSD_HOST: str({default: '172.17.0.1'}),
13-
BEARER_TOKEN: str({devDefault: 'PIZZA'}),
14-
IS_ENTERPRISE: bool({default: false}),
15-
NEXUS_SECRET: str({devDefault: 'test', default: ''}),
16-
NEXUS_URL: str({devDefault: 'http://127.0.0.1:8081/repository', default: ''}),
17-
NEXUS_REPOSITORY: str({devDefault: 'my-npm', default: ''}),
18-
NEXUS_INSTALLATION: str({devDefault: '1', default: ''})
5+
PORT: num({ default: 5000 }),
6+
WEBHOOKS_SECRET: str({ devDefault: 'YOLO' }),
7+
NPMHOOKS_SECRET: str({ devDefault: 'SWAG' }),
8+
QUEUE_NAME: str({ default: 'events' }),
9+
AMQP_URL: url({ devDefault: 'amqp://localhost?heartbeat=15' }),
10+
NODE_ENV: str({ choices: ['development', 'staging', 'production'], devDefault: 'development' }),
11+
ROLLBAR_TOKEN_HOOKS: str({ devDefault: '' }),
12+
STATSD_HOST: str({ default: '172.17.0.1' }),
13+
BEARER_TOKEN: str({ devDefault: 'PIZZA' }),
14+
IS_ENTERPRISE: bool({ default: false }),
15+
NEXUS_SECRET: str({ devDefault: 'test', default: '' }),
16+
NEXUS_URL: str({ devDefault: 'http://127.0.0.1:8081/repository', default: '' }),
17+
NEXUS_REPOSITORY: str({ devDefault: 'my-npm', default: '' }),
18+
NEXUS_INSTALLATION: str({ devDefault: '1', default: '' })
1919
})

lib/github-event.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports.attributes = {
5252
name: 'github'
5353
}
5454

55-
function githubEvent (server, {env, channel}, next) {
55+
function githubEvent (server, { env, channel }, next) {
5656
server.route({
5757
method: 'POST',
5858
path: '/github',
@@ -68,20 +68,20 @@ function githubEvent (server, {env, channel}, next) {
6868
async function handler (request, reply) {
6969
const eventName = request.headers['x-github-event']
7070

71-
if (_.includes(blacklist, eventName)) return reply({ok: true}).code(202)
71+
if (_.includes(blacklist, eventName)) return reply({ ok: true }).code(202)
7272

7373
const event = githubEvents[eventName] || {
7474
priority: 1
7575
}
7676

77-
const {payload} = request
77+
const { payload } = request
7878
const hmacPayload = crypto.createHmac('sha1', env.WEBHOOKS_SECRET)
7979
.update(payload)
8080
.digest('hex')
8181

8282
const signature = request.headers['x-hub-signature']
8383
if (`sha1=${hmacPayload}` !== signature) {
84-
return reply({error: true}).code(403)
84+
return reply({ error: true }).code(403)
8585
}
8686

8787
const parsedPayload = JSON.parse(payload.toString())
@@ -101,10 +101,10 @@ function githubEvent (server, {env, channel}, next) {
101101
remoteAddress: request.info.remoteAddress
102102
}
103103
}))
104-
return reply({error: true}).code(500)
104+
return reply({ error: true }).code(500)
105105
}
106106

107-
reply({ok: true}).code(202)
107+
reply({ ok: true }).code(202)
108108
}
109109

110110
next()

lib/nexus-event.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports.attributes = {
1010
name: 'nexus'
1111
}
1212

13-
function nexusEvent (server, {env, channel}, next) {
13+
function nexusEvent (server, { env, channel }, next) {
1414
server.route({
1515
method: 'POST',
1616
path: '/nexus/',
@@ -31,7 +31,7 @@ function nexusEvent (server, {env, channel}, next) {
3131
const nexusInstallation = env.NEXUS_INSTALLATION
3232

3333
if (!nexusSecret || !nexusUrl || !nexusRepository || !nexusInstallation) {
34-
return reply({ok: false}).code(503) // Service Unavailable
34+
return reply({ ok: false }).code(503) // Service Unavailable
3535
}
3636

3737
const payload = request.payload.toString()
@@ -42,19 +42,19 @@ function nexusEvent (server, {env, channel}, next) {
4242
.digest('hex')
4343

4444
if (signature !== hmacDigest) {
45-
return reply({ok: false}).code(403)
45+
return reply({ ok: false }).code(403)
4646
}
4747

4848
let update
4949
try {
5050
update = JSON.parse(payload)
5151
// we can only parse out the version on here
5252
if (update.action !== 'CREATED') {
53-
return reply({ok: true}).code(200)
53+
return reply({ ok: true }).code(200)
5454
}
5555
} catch (e) {
5656
console.log(e)
57-
return reply({error: true}).code(401)
57+
return reply({ error: true }).code(401)
5858
}
5959

6060
const name = update.asset.name.split('/-/')[0]
@@ -82,7 +82,7 @@ function nexusEvent (server, {env, channel}, next) {
8282
}
8383

8484
try {
85-
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), {priority: 1})
85+
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), { priority: 1 })
8686
} catch (err) {
8787
console.log('rollbar', err)
8888
rollbar.error(err, _.assign({}, request.raw.req, {
@@ -93,10 +93,10 @@ function nexusEvent (server, {env, channel}, next) {
9393
remoteAddress: request.info.remoteAddress
9494
}
9595
}))
96-
return reply({error: true}).code(501)
96+
return reply({ error: true }).code(501)
9797
}
9898

99-
reply({ok: true}).code(202)
99+
reply({ ok: true }).code(202)
100100
}
101101
next()
102102
}

lib/npm-event.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports.attributes = {
99
name: 'npm'
1010
}
1111

12-
function npmEvent (server, {env, channel}, next) {
12+
function npmEvent (server, { env, channel }, next) {
1313
server.route({
1414
method: 'POST',
1515
path: '/npm/{installation}',
@@ -29,14 +29,14 @@ function npmEvent (server, {env, channel}, next) {
2929
.update(installation)
3030
.digest('hex')
3131

32-
const {payload} = request
32+
const { payload } = request
3333
const hmacPayload = crypto.createHmac('sha256', secret)
3434
.update(payload)
3535
.digest('hex')
3636

3737
const signature = request.headers['x-npm-signature']
3838
if (`sha256=${hmacPayload}` !== signature) {
39-
return reply({error: true}).code(403)
39+
return reply({ error: true }).code(403)
4040
}
4141

4242
var parsedPayload, distTags, versions
@@ -45,7 +45,7 @@ function npmEvent (server, {env, channel}, next) {
4545
distTags = parsedPayload['dist-tags']
4646
versions = _.mapValues(parsedPayload.versions, v => _.pick(v, ['gitHead', 'repository']))
4747
} catch (e) {
48-
return reply({error: true}).code(401)
48+
return reply({ error: true }).code(401)
4949
}
5050

5151
const job = {
@@ -58,7 +58,7 @@ function npmEvent (server, {env, channel}, next) {
5858
}
5959

6060
try {
61-
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), {priority: 1})
61+
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), { priority: 1 })
6262
} catch (err) {
6363
rollbar.error(err, _.assign({}, request.raw.req, {
6464
socket: {
@@ -68,10 +68,10 @@ function npmEvent (server, {env, channel}, next) {
6868
remoteAddress: request.info.remoteAddress
6969
}
7070
}))
71-
return reply({error: true}).code(500)
71+
return reply({ error: true }).code(500)
7272
}
7373

74-
reply({ok: true}).code(202)
74+
reply({ ok: true }).code(202)
7575
}
7676

7777
next()

lib/reset-event.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ module.exports.attributes = {
88
name: 'reset'
99
}
1010

11-
function resetEvent (server, {env, channel}, next) {
11+
function resetEvent (server, { env, channel }, next) {
1212
server.route({
1313
method: 'POST',
1414
path: '/reset',
1515
config: {
16-
pre: [{method: (request, reply) => {
16+
pre: [{ method: (request, reply) => {
1717
if (request.headers['bearer-token'] === env.BEARER_TOKEN) {
1818
return reply.continue()
1919
}
2020
return reply(Boom.unauthorized())
21-
}}]
21+
} }]
2222
},
2323
handler
2424
})
2525

2626
async function handler (request, reply) {
27-
if (!_.get(request, 'payload.repositoryFullName')) return reply({error: 'repositoryFullName missing'}).code(400)
27+
if (!_.get(request, 'payload.repositoryFullName')) return reply({ error: 'repositoryFullName missing' }).code(400)
2828

2929
const job = {
3030
name: 'reset',
@@ -33,7 +33,7 @@ function resetEvent (server, {env, channel}, next) {
3333
}
3434

3535
try {
36-
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), {priority: 5})
36+
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), { priority: 5 })
3737
} catch (err) {
3838
rollbar.error(err, _.assign({}, request.raw.req, {
3939
socket: {
@@ -43,10 +43,10 @@ function resetEvent (server, {env, channel}, next) {
4343
remoteAddress: request.info.remoteAddress
4444
}
4545
}))
46-
return reply({error: true}).code(500)
46+
return reply({ error: true }).code(500)
4747
}
4848

49-
reply({ok: true}).code(202)
49+
reply({ ok: true }).code(202)
5050
}
5151

5252
next()

lib/rollbar.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {resolve} = require('path')
1+
const { resolve } = require('path')
22

33
const Rollbar = require('rollbar')
44

@@ -18,5 +18,5 @@ if (enabled) {
1818
exitOnUncaughtException: true
1919
})
2020
} else {
21-
module.exports = new Rollbar({enabled: false})
21+
module.exports = new Rollbar({ enabled: false })
2222
}

lib/stripe-event.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ module.exports.attributes = {
77
name: 'stripe'
88
}
99

10-
function stripeEvent (server, {env, channel}, next) {
10+
function stripeEvent (server, { env, channel }, next) {
1111
server.route({
1212
method: 'POST',
1313
path: '/stripe',
1414
handler
1515
})
1616

1717
async function handler (request, reply) {
18-
if (!_.get(request, 'payload.id')) return reply({error: 'id missing'}).code(400)
18+
if (!_.get(request, 'payload.id')) return reply({ error: 'id missing' }).code(400)
1919

2020
const job = {
2121
name: 'stripe-event',
2222
id: request.payload.id
2323
}
2424

2525
try {
26-
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), {priority: 5})
26+
await channel.sendToQueue(env.QUEUE_NAME, Buffer.from(JSON.stringify(job)), { priority: 5 })
2727
} catch (err) {
2828
rollbar.error(err, _.assign({}, request.raw.req, {
2929
socket: {
@@ -33,10 +33,10 @@ function stripeEvent (server, {env, channel}, next) {
3333
remoteAddress: request.info.remoteAddress
3434
}
3535
}))
36-
return reply({error: true}).code(500)
36+
return reply({ error: true }).code(500)
3737
}
3838

39-
reply({ok: true}).code(202)
39+
reply({ ok: true }).code(202)
4040
}
4141

4242
next()

0 commit comments

Comments
 (0)