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 {
22 readonly id : string ;
33 readonly name : string ;
44 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` ) ;
44 }
55}
Original file line number Diff line number Diff line change 1- import Course from './Course' ;
21import { 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 > > ;
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' ;
33import fs from 'fs' ;
44import BSON from 'bson' ;
55import { 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 > > {
Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 11import { Request , Response } from 'express' ;
22import httpStatus from 'http-status' ;
3- import Controller from './Controller' ;
3+ import { Controller } from './Controller' ;
44
55export default class StatusGetController implements Controller {
66 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' ;
33
44describe ( 'Save Course' , ( ) => {
55 it ( 'should have a course' , ( ) => {
You can’t perform that action at this time.
0 commit comments