Skip to content

Commit d93bec8

Browse files
committed
add launch_library_id to launch schema
1 parent 6d39492 commit d93bec8

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ Temporary Items
9090

9191
TODO.md
9292
test.json
93-
spacex-api
93+
spacex-api
94+
.envrc

lib/healthchecks/fail.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ const { HEALTHCHECK_PREFIX } = require('../constants');
77
/**
88
* Send fail signal to healthcheck.io
99
*
10-
* @param {String} id UUID of healthcheck
10+
* @param {String} [id] UUID of healthcheck
1111
* @param {String|Object} [msg] Message to pass to healthcheck
1212
* @returns {Boolean} True if successful
1313
*/
14-
module.exports = async (id, msg = {}) => {
15-
const response = await got.post({
16-
prefixUrl: HEALTHCHECK_PREFIX,
17-
url: `${id}/fail`,
18-
json: msg,
19-
});
20-
if (response.statusCode === 200) {
21-
return true;
14+
module.exports = async (id = null, msg = {}) => {
15+
if (id) {
16+
const response = await got.post({
17+
prefixUrl: HEALTHCHECK_PREFIX,
18+
url: `${id}/fail`,
19+
json: msg,
20+
});
21+
if (response.statusCode === 200) {
22+
return true;
23+
}
2224
}
2325
return false;
2426
};

lib/healthchecks/start.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ const { HEALTHCHECK_PREFIX } = require('../constants');
77
/**
88
* Send start signal to healthcheck.io
99
*
10-
* @param {String} id UUID of healthcheck
10+
* @param {String} [id] UUID of healthcheck
1111
* @param {String|Object} [msg] Message to pass to healthcheck
12-
* @returns {Boolean} true if successful
12+
* @returns {Boolean} True if successful
1313
*/
14-
module.exports = async (id, msg = {}) => {
15-
const response = await got.post({
16-
prefixUrl: HEALTHCHECK_PREFIX,
17-
url: `${id}/start`,
18-
json: msg,
19-
});
20-
if (response.statusCode === 200) {
21-
return true;
14+
module.exports = async (id = null, msg = {}) => {
15+
if (id) {
16+
const response = await got.post({
17+
prefixUrl: HEALTHCHECK_PREFIX,
18+
url: `${id}/start`,
19+
json: msg,
20+
});
21+
if (response.statusCode === 200) {
22+
return true;
23+
}
2224
}
2325
return false;
2426
};

lib/healthchecks/success.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ const { HEALTHCHECK_PREFIX } = require('../constants');
1111
* @param {String|Object} [msg] Message to pass to healthcheck
1212
* @returns {Boolean} True if successful
1313
*/
14-
module.exports = async (id, msg = {}) => {
15-
const response = await got.post({
16-
prefixUrl: HEALTHCHECK_PREFIX,
17-
url: `${id}`,
18-
json: msg,
19-
});
20-
if (response.statusCode === 200) {
21-
return true;
14+
module.exports = async (id = null, msg = {}) => {
15+
if (id) {
16+
const response = await got.post({
17+
prefixUrl: HEALTHCHECK_PREFIX,
18+
url: `${id}`,
19+
json: msg,
20+
});
21+
if (response.statusCode === 200) {
22+
return true;
23+
}
2224
}
2325
return false;
2426
};

routes/v4/launches/model.js

+4
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ const launchSchema = new mongoose.Schema({
218218
type: Boolean,
219219
default: true,
220220
},
221+
launch_library_id: {
222+
type: String,
223+
default: null,
224+
},
221225
}, { autoCreate: true });
222226

223227
const index = {

0 commit comments

Comments
 (0)