File tree Expand file tree Collapse file tree 7 files changed +15
-15
lines changed
apps/mooc_backend/controllers
tests/Contexts/Mooc/Courses/infrastructure Expand file tree Collapse file tree 7 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 1
- export default class Course {
1
+ export class Course {
2
2
readonly id : string ;
3
3
readonly name : string ;
4
4
readonly duration : string ;
Original file line number Diff line number Diff line change 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` ) ;
4
4
}
5
5
}
Original file line number Diff line number Diff line change 1
- import Course from './Course' ;
2
1
import { Nullable } from '../../../Shared/domain/Nullable' ;
2
+ import { Course } from './Course' ;
3
3
4
- export default interface CourseRepository {
4
+ export interface CourseRepository {
5
5
save ( course : Course ) : Promise < void > ;
6
6
7
7
search ( id : string ) : Promise < Nullable < Course > > ;
Original file line number Diff line number Diff line change 1
- import CourseRepository from '../domain/CourseRepository' ;
2
- import Course from '../domain/Course' ;
1
+ import { CourseRepository } from '../domain/CourseRepository' ;
2
+ import { Course } from '../domain/Course' ;
3
3
import fs from 'fs' ;
4
4
import BSON from 'bson' ;
5
5
import { Nullable } from '../../../Shared/domain/Nullable' ;
6
6
7
- export default class FileCourseRepository implements CourseRepository {
7
+ export class FileCourseRepository implements CourseRepository {
8
8
private FILE_PATH = `${ __dirname } /courses` ;
9
9
10
10
async save ( course : Course ) : Promise < void > {
11
11
const filePath = this . filePath ( course . id ) ;
12
12
const data = BSON . serialize ( course ) ;
13
13
14
- return fs . writeFileSync ( filePath , data ) ;
14
+ return fs . writeFileSync ( filePath , data ) ;
15
15
}
16
16
17
17
async search ( id : string ) : Promise < Nullable < Course > > {
Original file line number Diff line number Diff line change 1
- import { Request , Response } from 'express' ;
1
+ import { Request , Response } from 'express' ;
2
2
3
- export default interface Controller {
3
+ export interface Controller {
4
4
run ( req : Request , res : Response ) : Promise < void > ;
5
5
}
Original file line number Diff line number Diff line change 1
1
import { Request , Response } from 'express' ;
2
2
import httpStatus from 'http-status' ;
3
- import Controller from './Controller' ;
3
+ import { Controller } from './Controller' ;
4
4
5
5
export default class StatusGetController implements Controller {
6
6
async run ( req : Request , res : Response ) {
Original file line number Diff line number Diff line change 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' ;
3
3
4
4
describe ( 'Save Course' , ( ) => {
5
5
it ( 'should have a course' , ( ) => {
You can’t perform that action at this time.
0 commit comments