Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function* createGistSaga(action: ActionType) {
const token = yield select(selectors.github.getToken)
if (!token) {
return
}
const solution: ISolution = yield select(
selectors.solutions.get,
action.payload.solutionId,
)
const snippet = YAML.stringify(convertSolutionToSnippet(solution))
const { response, error } = yield call(github.request, {
method: 'POST',
path: 'gists',
token,
jsonPayload: JSON.stringify({
public: action.payload.isPublic,
description: `${solution.description}`,
files: {
[`${solution.name}.yaml`]: {
content: snippet,
},
},
}),
})
function* updateGistSaga(action: ActionType) {
const token = yield select(selectors.github.getToken)
if (!token) {
return
}
const solution = yield select(selectors.solutions.get, action.payload.solutionId)
const snippet = YAML.stringify(convertSolutionToSnippet(solution))
const gistId = solution.source.id
if (!gistId) {
yield put(gists.update.failure(new Error('No gistId for this solution.')))
} else {
const { response, error } = yield call(github.request, {
method: 'PATCH',
path: `gists/${gistId}`,
token,
jsonPayload: JSON.stringify({
description: `${solution.description}`,
files: {
[`${solution.name}.yaml`]: {
content: snippet,
},
},
getSnippetYaml = (): string =>
YAML.stringify(convertSolutionToSnippet(this.props.solution))