diff --git a/src/apps.js b/src/apps.js index b047701fe..c8495276e 100644 --- a/src/apps.js +++ b/src/apps.js @@ -10,6 +10,7 @@ exports = module.exports = { update, setHealth, del, + delPortBinding, get, getByIpAddress, @@ -817,6 +818,14 @@ async function del(id) { if (results[5].affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'App not found'); } +async function delPortBinding(hostPort, type) { + assert.strictEqual(typeof hostPort, 'number'); + assert.strictEqual(typeof type, 'string'); + + const result = await database.query('DELETE FROM appPortBindings WHERE hostPort=? AND type=?', [ hostPort, type ]); + if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'App not found'); +} + async function clear() { await database.query('DELETE FROM subdomains'); await database.query('DELETE FROM appPortBindings');