Skip to content

Commit 9885678

Browse files
committed
Use named export/import
1 parent 1de4cc1 commit 9885678

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

src/Contexts/Mooc/Courses/domain/Course.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default class Course {
1+
export class Course {
22
readonly id: string;
33
readonly name: string;
44
readonly duration: string;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export default class CourseAlreadyExists extends Error {
2-
constructor(courseId: string) {
3-
super(`Course ${courseId} already exists`);
1+
export class CourseAlreadyExists extends Error {
2+
constructor(id: string) {
3+
super(`Course ${id} already exists`);
44
}
55
}

src/Contexts/Mooc/Courses/domain/CourseRepository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Course from './Course';
21
import { Nullable } from '../../../Shared/domain/Nullable';
2+
import { Course } from './Course';
33

4-
export default interface CourseRepository {
4+
export interface CourseRepository {
55
save(course: Course): Promise<void>;
66

77
search(id: string): Promise<Nullable<Course>>;

src/Contexts/Mooc/Courses/infrastructure/FileCourseRepository.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import CourseRepository from '../domain/CourseRepository';
2-
import Course from '../domain/Course';
1+
import { CourseRepository } from '../domain/CourseRepository';
2+
import { Course } from '../domain/Course';
33
import fs from 'fs';
44
import BSON from 'bson';
55
import { Nullable } from '../../../Shared/domain/Nullable';
66

7-
export default class FileCourseRepository implements CourseRepository {
7+
export class FileCourseRepository implements CourseRepository {
88
private FILE_PATH = `${__dirname}/courses`;
99

1010
async save(course: Course): Promise<void> {
1111
const filePath = this.filePath(course.id);
1212
const data = BSON.serialize(course);
1313

14-
return fs.writeFileSync(filePath, data);
14+
return fs.writeFileSync(filePath, data);
1515
}
1616

1717
async search(id: string): Promise<Nullable<Course>> {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Request, Response} from 'express';
1+
import { Request, Response } from 'express';
22

3-
export default interface Controller {
3+
export interface Controller {
44
run(req: Request, res: Response): Promise<void>;
55
}

src/apps/mooc_backend/controllers/StatusGetController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request, Response } from 'express';
22
import httpStatus from 'http-status';
3-
import Controller from './Controller';
3+
import { Controller } from './Controller';
44

55
export default class StatusGetController implements Controller {
66
async run(req: Request, res: Response) {

tests/Contexts/Mooc/Courses/infrastructure/FileCourseRepository.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import FileCourseRepository from '../../../../../src/Contexts/Mooc/Courses/infrastructure/FileCourseRepository';
2-
import Course from '../../../../../src/Contexts/Mooc/Courses/domain/Course';
1+
import { FileCourseRepository } from '../../../../../src/Contexts/Mooc/Courses/infrastructure/FileCourseRepository';
2+
import { Course } from '../../../../../src/Contexts/Mooc/Courses/domain/Course';
33

44
describe('Save Course', () => {
55
it('should have a course', () => {

0 commit comments

Comments
 (0)