Skip to content

Commit 71b8f3a

Browse files
committed
Add CoursesCounter module
2 parents a746312 + 3e9368a commit 71b8f3a

File tree

67 files changed

+634
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+634
-77
lines changed

.github/workflows/nodejs.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
strategy:
1110
matrix:
1211
node-version: [8.x, 10.x, 12.x]
12+
mongodb-version: [4.0, 4.2]
1313

1414
steps:
15-
- uses: actions/checkout@v1
16-
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
18-
with:
19-
node-version: ${{ matrix.node-version }}
20-
- name: npm install, build, and test
21-
run: |
22-
npm install
23-
npm run build --if-present
24-
npm test
25-
env:
26-
CI: true
15+
- uses: actions/checkout@v1
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- name: Launch MongoDB
21+
uses: wbari/start-mongoDB@v0.2
22+
with:
23+
mongoDBVersion: ${{ matrix.mongodb-version }}
24+
- name: npm install, build, and test
25+
run: |
26+
npm install
27+
npm run build --if-present
28+
npm test
29+
env:
30+
CI: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ node_modules/
22
dist/
33
.tmp
44
logs/
5-
src/Contexts/Mooc/Courses/infrastructure/courses.*
5+
src/Contexts/Mooc/Courses/infrastructure/persistence/courses.*

cucumber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let common = [
2-
'tests/**/features/*.feature', // Specify our feature files
2+
'tests/**/features/**/*.feature', // Specify our feature files
33
'--require-module ts-node/register', // Load TypeScript module
44
'--require tests/**/features/step_definitions/*.steps.ts' // Load step definitions
55
].join(' ');

package-lock.json

Lines changed: 84 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@types/express": "^4.17.2",
2626
"@types/glob": "^7.1.1",
2727
"@types/helmet": "0.0.44",
28+
"@types/mongodb": "^3.3.15",
2829
"@types/node": "~13.1.1",
2930
"@types/uuid": "^3.4.6",
3031
"@types/uuid-validate": "0.0.1",
@@ -39,6 +40,7 @@
3940
"helmet": "^3.21.2",
4041
"http-status": "^1.4.2",
4142
"mandrill-api": "^1.0.45",
43+
"mongodb": "^3.5.2",
4244
"node-dependency-injection": "^2.4.2",
4345
"ts-node": "^8.3.0",
4446
"typescript": "^3.7.2",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ export abstract class AggregateRoot {
1414
record(event: DomainEvent): void {
1515
this.domainEvents.push(event);
1616
}
17+
18+
abstract toPrimitives(): any;
1719
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,20 @@ export class Course extends AggregateRoot {
2929

3030
return course;
3131
}
32+
33+
static fromPrimitives(plainData: any): Course {
34+
return new Course(
35+
new CourseId(plainData.id),
36+
new CourseName(plainData.name),
37+
new CourseDuration(plainData.duration)
38+
);
39+
}
40+
41+
toPrimitives(): any {
42+
return {
43+
id: this.id.value,
44+
name: this.name.value,
45+
duration: this.duration.value
46+
};
47+
}
3248
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)