From 543cb11e690b563214dcfce674ef7e4955b7c437 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sat, 8 May 2021 12:41:41 +1200 Subject: [PATCH] Change package manager request signature --- api/src/api/v2.js | 8 ++++---- api/src/config.js | 2 +- cli/commands/ppman_commands/install.js | 5 ++++- cli/commands/ppman_commands/uninstall.js | 5 ++++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/api/src/api/v2.js b/api/src/api/v2.js index e3e8c68..948dccf 100644 --- a/api/src/api/v2.js +++ b/api/src/api/v2.js @@ -163,10 +163,10 @@ router.get('/packages', async (req, res) => { return res.status(200).send(packages); }); -router.post('/packages/:language/:version', async (req, res) => { +router.post('/packages', async (req, res) => { logger.debug('Request to install package'); - const { language, version } = req.params; + const { language, version } = req.body; const pkg = await package.get_package(language, version); @@ -192,10 +192,10 @@ router.post('/packages/:language/:version', async (req, res) => { } }); -router.delete('/packages/:language/:version', async (req, res) => { +router.delete('/packages', async (req, res) => { logger.debug('Request to uninstall package'); - const { language, version } = req.params; + const { language, version } = req.body; const pkg = await package.get_package(language, version); diff --git a/api/src/config.js b/api/src/config.js index acf45ce..84270aa 100644 --- a/api/src/config.js +++ b/api/src/config.js @@ -16,7 +16,7 @@ const options = [ }, { key: 'bind_address', - desc: 'Address to bind REST API on\nThank @Bones for the number', + desc: 'Address to bind REST API on', default: '0.0.0.0:2000', validators: [], }, diff --git a/cli/commands/ppman_commands/install.js b/cli/commands/ppman_commands/install.js index 3a71410..4e48c20 100644 --- a/cli/commands/ppman_commands/install.js +++ b/cli/commands/ppman_commands/install.js @@ -12,7 +12,10 @@ const msg_format = { exports.handler = async ({ axios, language, version }) => { try { - const install = await axios.post(`/api/v2/packages/${language}/${version || '*'}`); + const install = await axios.post(`/api/v2/packages`, { + language, + version: version || '*' + }); console.log(msg_format.color(install.data)); } catch ({ response }) { diff --git a/cli/commands/ppman_commands/uninstall.js b/cli/commands/ppman_commands/uninstall.js index 54a8165..1ea9161 100644 --- a/cli/commands/ppman_commands/uninstall.js +++ b/cli/commands/ppman_commands/uninstall.js @@ -12,7 +12,10 @@ const msg_format = { exports.handler = async ({ axios, language, version }) => { try { - const uninstall = await axios.delete(`/api/v2/packages/${language}/${version || '*'}`) + const install = await axios.delete(`/api/v2/packages`, { + language, + version: version || '*' + }); console.log(msg_format.color(uninstall.data)); } catch ({ response }) {