#167 trim of the title in the moment of creation of new project

parent 121ad939
......@@ -17,6 +17,10 @@ router.get('/',async (req:Request, res:Response): Promise<Response>=> {
}
})
/**get projects were user is member, by user token */
router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
try{
......@@ -56,11 +60,12 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
try{
if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'})
const {user, title,color}= req.body;
const titleTrimed = title.trim()
const projectCheck = await dataSource
.getRepository(Project)
.find({
where:{
title:title
title:titleTrimed
}})
if(projectCheck.length>0) {return res.status(400).send({message:"suchc Project already exists"})}
const member:Member = new Member;
......@@ -68,7 +73,7 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
member.roleProject= MemberRole.ADMIN;
await member.save();
const project : Project= new Project()
project.title = title;
project.title = titleTrimed;
project.color = color;
project.members=[member]
await project.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment