Skip to content

Commit 27a116e

Browse files
committed
Merge branch 'fix/backend-modules-application' of github.com:mathieusouflis/turing-app-clean-architecture into fix/backend-modules-application
# Conflicts: # apps/backend/package.json # apps/backend/src/infrastructure/database/index.ts
2 parents df991bf + 981cd08 commit 27a116e

File tree

12 files changed

+718
-10
lines changed

12 files changed

+718
-10
lines changed

apps/backend/TESTING.md

Lines changed: 697 additions & 0 deletions
Large diffs are not rendered by default.

apps/backend/src/application/controllers/use-cases/delete-tape.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export class DeleteTapeUseCase {
1414
* @returns true if deleted, false if not found
1515
*/
1616
async execute(id: string): Promise<boolean> {
17-
return await this.repository.delete(id);
17+
const tape = await this.repository.get(id);
18+
if (!tape) {
19+
return false;
20+
}
21+
await this.repository.delete(id);
22+
return true;
1823
}
1924
}

apps/backend/src/application/controllers/use-cases/execute-steps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ExecuteStepUseCase {
1818
*/
1919
async execute(id: string): Promise<TapeRecord | null> {
2020
// Load tape from database
21-
const record = await this.repository.findById(id);
21+
const record = await this.repository.get(id);
2222
if (!record) {
2323
return null;
2424
}

apps/backend/src/application/controllers/use-cases/get-tape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ export class GetTapeUseCase {
1515
* @returns Tape record or null if not found
1616
*/
1717
async execute(id: string): Promise<TapeRecord | null> {
18-
return await this.repository.findById(id);
18+
return await this.repository.get(id);
1919
}
2020
}

apps/backend/src/application/controllers/use-cases/reset-tape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ResetTapeUseCase {
1818
*/
1919
async execute(id: string): Promise<TapeRecord | null> {
2020
// Load tape from database
21-
const record = await this.repository.findById(id);
21+
const record = await this.repository.get(id);
2222
if (!record) {
2323
return null;
2424
}

apps/backend/src/application/controllers/use-cases/run-machine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class RunMachineUseCase {
2626
options: RunMachineRequest = {}
2727
): Promise<{ tape: TapeRecord; stepsExecuted: number } | null> {
2828
// Load tape from database
29-
const record = await this.repository.findById(id);
29+
const record = await this.repository.get(id);
3030
if (!record) {
3131
return null;
3232
}

apps/backend/src/application/use-cases/delete-tape.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ export class DeleteTapeUseCase {
1414
* @returns true if deleted, false if not found
1515
*/
1616
async execute(id: string): Promise<boolean> {
17-
return await this.repository.delete(id);
17+
const tape = await this.repository.get(id);
18+
if (!tape) {
19+
return false;
20+
}
21+
await this.repository.delete(id);
22+
return true;
1823
}
1924
}
2025

apps/backend/src/application/use-cases/execute-step.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ExecuteStepUseCase {
1818
*/
1919
async execute(id: string): Promise<TapeRecord | null> {
2020
// Load tape from database
21-
const record = await this.repository.findById(id);
21+
const record = await this.repository.get(id);
2222
if (!record) {
2323
return null;
2424
}

apps/backend/src/application/use-cases/get-tape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class GetTapeUseCase {
1515
* @returns Tape record or null if not found
1616
*/
1717
async execute(id: string): Promise<TapeRecord | null> {
18-
return await this.repository.findById(id);
18+
return await this.repository.get(id);
1919
}
2020
}
2121

apps/backend/src/application/use-cases/reset-tape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ResetTapeUseCase {
1818
*/
1919
async execute(id: string): Promise<TapeRecord | null> {
2020
// Load tape from database
21-
const record = await this.repository.findById(id);
21+
const record = await this.repository.get(id);
2222
if (!record) {
2323
return null;
2424
}

0 commit comments

Comments
 (0)