Skip to content

Commit

Permalink
fixed delete message return
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalvagno committed Dec 16, 2024
1 parent 37edc7f commit 037a1fa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
18 changes: 10 additions & 8 deletions routes/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,26 @@ 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 );
return res.status(500).json({error:e});
})
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 );
Expand Down
7 changes: 5 additions & 2 deletions services/prisma/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}){
Expand Down
6 changes: 3 additions & 3 deletions services/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}){
Expand Down
9 changes: 9 additions & 0 deletions zooprocess.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -1719,6 +1723,11 @@ components:

schemas:

Message:
properties:
message:
type: string

Drive:
required:
- id
Expand Down

0 comments on commit 037a1fa

Please sign in to comment.