Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/domain/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export abstract class Entity<T> {
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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/domain/UniqueEntityID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import uuid from 'uuid/v4';
import { Identifier } from './Identifier'

export class UniqueEntityID extends Identifier<string | number>{
constructor (id?: string | number) {
super(id ? id : uuid())
constructor (id: string | number = uuid()) {
super(id);
}
}
6 changes: 3 additions & 3 deletions src/core/domain/WatchedList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export abstract class WatchedList<T> {
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 = [];
}
Expand Down
28 changes: 14 additions & 14 deletions src/core/infra/BaseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down