Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function completeCheckRun(
{label, repo, installationToken, checkId, markdown}: {
label: string,
repo: string,
checkId: string,
markdown: string,
installationToken: string
}) {
await got.patch(
`https://api.github.com/repos/${repo}/check-runs/${checkId}`, {
headers: {
Accept: 'application/vnd.github.antiope-preview+json',
Authorization: `Bearer ${installationToken}`,
},
// https://developer.github.com/v3/checks/runs/#parameters-1
body: JSON.stringify({
name: label,
completed_at: new Date().toISOString(),
// Note that in the future we will likely want to be able to report
// a failing check (e.g. if there appears to be a difference greater
// than some threshold).
conclusion: 'neutral',
output: {
title: label,
summary: 'Benchmark results',
export default async function (model, data) {
try {
if (!this.isAuth) throw new Error('Not authenticated')
if (typeof data.id === 'undefined') throw new Error('PATCH request is missing a model ID')
// Handle request
const opts = Object.assign({
body: JSON.stringify(serialise(model, data, 'PATCH'))
}, this._opts)
await r.patch(`${this._apiUrl}/${this._apiVer}/${kebab(model, '-')}/${data.id}`, opts)
.catch(e => { throw e.response.body })
} catch (e) {
throw e
}
}
optIn(user, groupId) {
arg.checkIfExists(user, 'user');
arg.checkIfNumber(groupId, 'groupId');
const path = this.firebaseSettings.buildPath(`groups/${groupId}/members/${user.id}.json`);
const payload = JSON.stringify({
id: user.id,
username: user.username,
optIn: true
});
return got.patch(path, {
body: payload
}).catch(err => {
console.log(err);
});
}
optOut(user, groupId) {
arg.checkIfExists(user, 'user');
arg.checkIfNumber(groupId, 'groupId');
const path = this.firebaseSettings.buildPath(`groups/${groupId}/members/${user.id}.json`);
const payload = JSON.stringify({
id: user.id,
username: user.username,
optIn: false
});
return got.patch(path, {
body: payload
}).catch(err => {
console.log(err);
});
}
}
exports.editComment = async ({ owner, repo, id, body }: EditCommentsParams) => {
await got.patch(`${BASE_URI}/repos/${owner}/${repo}/issues/comments/${id}`, {
body: JSON.stringify({ body }),
headers,
json: true,
});
};
async requestReviewOnBreachesCollection() {
const auth = `${FX_RS_WRITER_USER}:${FX_RS_WRITER_PASS}`;
return await got.patch(FX_RS_COLLECTION, {
json: true, auth, body: { data: {status: "to-review"} },
});
},
};
rename(name, callback) {
let retval = {
success: false,
data: {},
};
Logger.verbose('Requesting nodes:files:patch endpoint (rename)');
Logger.debug(`HTTP Request: PATCH '${account.metadataUrl}nodes/${this.getId()}'`);
got.patch(`${account.metadataUrl}nodes/${this.getId()}`, {
headers: {
Authorization: `Bearer ${account.token.access_token}`
},
body: JSON.stringify({
name: name,
})
})
.then(response => {
Logger.debug(`Response returned with status code ${response.statusCode}.`);
Logger.silly(`Response body: ${response.body}`);
retval.data = JSON.parse(response.body);
if (response.statusCode === 200) {
retval.success = true;
this.replace(retval.data);
update(options, callback) {
let retval = {
success: false,
data: {},
};
Logger.verbose('Requesting nodes:files:patch endpoint (update)');
Logger.debug(`HTTP Request: PATCH '${account.metadataUrl}nodes/${this.getId()}'`);
got.patch(`${account.metadataUrl}nodes/${this.getId()}`, {
headers: {
Authorization: `Bearer ${account.token.access_token}`
},
body: JSON.stringify({
labels: options.labels || this.getLabels(),
description: options.description || this.getDescription(),
})
})
.then(response => {
Logger.debug(`Response returned with status code ${response.statusCode}.`);
Logger.silly(`Response body: ${response.body}`);
retval.data = JSON.parse(response.body);
if (response.statusCode === 200) {
retval.success = true;
this.replace(retval.data);