Adding dev endpoint to clear lock.
This commit is contained in:
parent
2021c59dd9
commit
3f75ebf853
|
@ -2,6 +2,8 @@ const fetch = require("node-fetch")
|
||||||
const env = require("../../environment")
|
const env = require("../../environment")
|
||||||
const { checkSlashesInUrl } = require("../../utilities")
|
const { checkSlashesInUrl } = require("../../utilities")
|
||||||
const { request } = require("../../utilities/workerRequests")
|
const { request } = require("../../utilities/workerRequests")
|
||||||
|
const { getGlobalIDFromUserMetadataID } = require("../../db/utils")
|
||||||
|
const { clearLock } = require("../../utilities/redis")
|
||||||
|
|
||||||
async function redirect(ctx, method) {
|
async function redirect(ctx, method) {
|
||||||
const { devPath } = ctx.params
|
const { devPath } = ctx.params
|
||||||
|
@ -32,3 +34,16 @@ exports.redirectPost = async ctx => {
|
||||||
exports.redirectDelete = async ctx => {
|
exports.redirectDelete = async ctx => {
|
||||||
await redirect(ctx, "DELETE")
|
await redirect(ctx, "DELETE")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.removeLock = async ctx => {
|
||||||
|
const { appId } = ctx.params
|
||||||
|
const globalUserId = getGlobalIDFromUserMetadataID(ctx.user._id)
|
||||||
|
try {
|
||||||
|
await clearLock(appId, globalUserId)
|
||||||
|
} catch (err) {
|
||||||
|
ctx.throw(400, "Unable to remove lock.")
|
||||||
|
}
|
||||||
|
ctx.body = {
|
||||||
|
message: "Lock removed successfully."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const Router = require("@koa/router")
|
const Router = require("@koa/router")
|
||||||
const controller = require("../controllers/dev")
|
const controller = require("../controllers/dev")
|
||||||
const env = require("../../environment")
|
const env = require("../../environment")
|
||||||
|
const authorized = require("../../middleware/authorized")
|
||||||
|
const { BUILDER } = require("../../utilities/security/permissions")
|
||||||
|
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
|
@ -11,4 +13,6 @@ if (env.isDev() || env.isTest()) {
|
||||||
.delete("/api/admin/:devPath(.*)", controller.redirectDelete)
|
.delete("/api/admin/:devPath(.*)", controller.redirectDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
router.delete("/api/dev/:appId/lock", authorized(BUILDER), controller.removeLock)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
Loading…
Reference in New Issue