Last active
September 27, 2018 13:03
-
-
Save barisere/caec5970fa3faf6900302eed017599a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file resource-controllers.js | |
const { makeWorker, cancelJob } = require("./undo-queue"); | |
async function deleteResource (/* parameters */) { | |
// code to delete the resource | |
} | |
const scheduleResourceDeletion = makeWorker(deleteResource); | |
exports.delete = function (req, res, next) { | |
const id = req.params.id; | |
// get other request data as necessary | |
scheduleResourceDeletion(id /* other arguments */) | |
.then(jobId => res.status(200).json({ jobId }).end()) | |
.catch(next); | |
}; | |
exports.cancelDelete = function (req, res, next) { | |
const jobId = req.query.id; | |
cancelJob(jobId) | |
.then(success => res.status(200).json({ success }).end()) | |
.catch(next); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment