diff --git a/src/core/domain/Entity.ts b/src/core/domain/Entity.ts index 34f23c9..2be18a8 100644 --- a/src/core/domain/Entity.ts +++ b/src/core/domain/Entity.ts @@ -9,8 +9,8 @@ export abstract class Entity { protected readonly _id: UniqueEntityID; public readonly props: T; - constructor (props: T, id?: UniqueEntityID) { - this._id = id ? id : new UniqueEntityID(); + constructor (props: T, id = new UniqueEntityID() ) { + this._id = id; this.props = props; } diff --git a/src/core/domain/UniqueEntityID.ts b/src/core/domain/UniqueEntityID.ts index fd76e4f..3a90080 100644 --- a/src/core/domain/UniqueEntityID.ts +++ b/src/core/domain/UniqueEntityID.ts @@ -3,7 +3,7 @@ import uuid from 'uuid/v4'; import { Identifier } from './Identifier' export class UniqueEntityID extends Identifier{ - constructor (id?: string | number) { - super(id ? id : uuid()) + constructor (id: string | number = uuid()) { + super(id); } } \ No newline at end of file diff --git a/src/core/domain/WatchedList.ts b/src/core/domain/WatchedList.ts index 54edf55..0694997 100644 --- a/src/core/domain/WatchedList.ts +++ b/src/core/domain/WatchedList.ts @@ -6,9 +6,9 @@ export abstract class WatchedList { private new: T[]; private removed: T[]; - constructor (initialItems?: T[]) { - this.currentItems = initialItems ? initialItems : []; - this.initial = initialItems ? initialItems : []; + constructor (initialItems: T[] = []) { + this.currentItems = initialItems; + this.initial = initialItems; this.new = []; this.removed = []; } diff --git a/src/core/infra/BaseController.ts b/src/core/infra/BaseController.ts index 653c515..faaed90 100644 --- a/src/core/infra/BaseController.ts +++ b/src/core/infra/BaseController.ts @@ -31,32 +31,32 @@ export abstract class BaseController { return res.sendStatus(201); } - public clientError (message?: string) { - return BaseController.jsonResponse(this.res, 400, message ? message : 'Unauthorized'); + public clientError (message = 'Unauthorized') { + return BaseController.jsonResponse(this.res, 400, message); } - public unauthorized (message?: string) { - return BaseController.jsonResponse(this.res, 401, message ? message : 'Unauthorized'); + public unauthorized (message = 'Unauthorized') { + return BaseController.jsonResponse(this.res, 401, message); } - public paymentRequired (message?: string) { - return BaseController.jsonResponse(this.res, 402, message ? message : 'Payment required'); + public paymentRequired (message = 'Payment required') { + return BaseController.jsonResponse(this.res, 402, message); } - public forbidden (message?: string) { - return BaseController.jsonResponse(this.res, 403, message ? message : 'Forbidden'); + public forbidden (message = 'Forbidden') { + return BaseController.jsonResponse(this.res, 403, message); } - public notFound (message?: string) { - return BaseController.jsonResponse(this.res, 404, message ? message : 'Not found'); + public notFound (message = 'Not found') { + return BaseController.jsonResponse(this.res, 404, message); } - public conflict (message?: string) { - return BaseController.jsonResponse(this.res, 409, message ? message : 'Conflict'); + public conflict (message = 'Conflict') { + return BaseController.jsonResponse(this.res, 409, message); } - public tooMany (message?: string) { - return BaseController.jsonResponse(this.res, 429, message ? message : 'Too many requests'); + public tooMany (message = 'Too many requests') { + return BaseController.jsonResponse(this.res, 429, message); } public todo () {