diff --git a/routes/projects.js b/routes/projects.js index 594ceeb..d085d77 100644 --- a/routes/projects.js +++ b/routes/projects.js @@ -96,13 +96,15 @@ module.exports = { delete: async (req,res) => { console.log("Projects::delete"); + const ref = req.params.projectId + const type = req.query.by || "name" switch ( type ) { case "name": - console.log("name: ", req.params.projectId); - return projects.deletename(req.params.projectId) - .then(project => { - return res.status(200).json({message:"Project " + string(req.params.projectId) + " deleted"}) + console.log("name: ", ref); + return projects.deletename(ref) + .then(() => { + return res.status(200).json({message:"Project " + ref + " deleted"}) }) .catch(async(e) =>{ console.error("Error:",e ); @@ -110,10 +112,10 @@ module.exports = { }) break; case "id": - console.log("id: ", req.params.projectId); - return projects.deleteid(req.params.projectId) - .then(project => { - return res.status(200).json({message:"Project " + string(req.params.projectId) + " deleted"}) + console.log("id: ", ref); + return projects.deleteid(ref) + .then(() => { + return res.status(200).json({message:"Project " + ref + " deleted"}) }) .catch(async(e) =>{ console.error("Error:",e ); diff --git a/services/prisma/projects.js b/services/prisma/projects.js index 58ee10c..528950b 100644 --- a/services/prisma/projects.js +++ b/services/prisma/projects.js @@ -355,16 +355,19 @@ module.exports.Projects = class { }) // return project - console.log( "" + id + "deleted") + console.log( id + " deleted") return {} } async deletename(name){ + console.debug("Project::deletename: ", name) await this.prisma.project.delete({ where:{ - name:id + name } }) + console.log( name + " deleted") + return {} } async delete({params}){ diff --git a/services/projects.js b/services/projects.js index 5dd0639..b49eb64 100644 --- a/services/projects.js +++ b/services/projects.js @@ -291,9 +291,9 @@ module.exports.Projects = class { return this.projects.deleteid(id) } - async deletename(id){ - console.debug("Project deleteid: ", id) - return this.projects.deletename(id) + async deletename(name){ + console.debug("Project deletename: ", name) + return this.projects.deletename(name) } async delete({params}){ diff --git a/zooprocess.openapi.yaml b/zooprocess.openapi.yaml index fb96ecf..129f600 100644 --- a/zooprocess.openapi.yaml +++ b/zooprocess.openapi.yaml @@ -182,6 +182,10 @@ paths: responses: '200': description: Returned is project deleted + content: + application/json: + schema: + $ref: '#/components/schemas/Message' '401': $ref: '#/components/responses/UnauthorizedError' '404': @@ -1719,6 +1723,11 @@ components: schemas: + Message: + properties: + message: + type: string + Drive: required: - id