#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>=> { ...@@ -17,6 +17,10 @@ router.get('/',async (req:Request, res:Response): Promise<Response>=> {
} }
}) })
/**get projects were user is member, by user token */ /**get projects were user is member, by user token */
router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> { router.get('/my',auth, async (req:Request, res:Response): Promise<Response>=> {
try{ try{
...@@ -56,11 +60,12 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => { ...@@ -56,11 +60,12 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
try{ try{
if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'}) if (!req.body) return res.status(400).send({Message:'problem in incoming req.body'})
const {user, title,color}= req.body; const {user, title,color}= req.body;
const titleTrimed = title.trim()
const projectCheck = await dataSource const projectCheck = await dataSource
.getRepository(Project) .getRepository(Project)
.find({ .find({
where:{ where:{
title:title title:titleTrimed
}}) }})
if(projectCheck.length>0) {return res.status(400).send({message:"suchc Project already exists"})} if(projectCheck.length>0) {return res.status(400).send({message:"suchc Project already exists"})}
const member:Member = new Member; const member:Member = new Member;
...@@ -68,7 +73,7 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => { ...@@ -68,7 +73,7 @@ router.post('/',auth, async (req:Request, res:Response): Promise<Response> => {
member.roleProject= MemberRole.ADMIN; member.roleProject= MemberRole.ADMIN;
await member.save(); await member.save();
const project : Project= new Project() const project : Project= new Project()
project.title = title; project.title = titleTrimed;
project.color = color; project.color = color;
project.members=[member] project.members=[member]
await project.save() 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