Check if date is valid before calling toISOString()

This commit is contained in:
Jerko Steiner 2019-08-25 22:20:28 +07:00
parent 91ecdbba10
commit 1e53f55cfa
3 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ import {
} from 'typeorm'
const transformer = {
from: (value: Date) => value.toISOString(),
from: (value: Date) => !isNaN(value.getTime()) ? value.toISOString() : value,
to: (value: undefined | null | string) => value ? new Date(value) : value,
}

View File

@ -62,8 +62,8 @@ describe('UserService', () => {
id: jasmine.any(Number),
userId: id,
email: username,
createDate: jasmine.any(Date),
updateDate: jasmine.any(Date),
createDate: jasmine.any(String),
updateDate: jasmine.any(String),
}])
})
})

View File

@ -31,7 +31,7 @@ export class TeamService implements ITeamService {
roleId: 1,
})
return team
return (await this.findOne(team.id))!
}
async remove({id, userId}: {id: number, userId: number}) {