Skip to content

Commit ddc1554

Browse files
committed
Merge remote-tracking branch 'upstream/master' into part_five_mongo_config
2 parents cff62cb + 90e5828 commit ddc1554

File tree

24 files changed

+2233
-2231
lines changed

24 files changed

+2233
-2231
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist/
44
logs/
55
src/Contexts/Mooc/Courses/infrastructure/persistence/courses.*
66
data
7+
test-results.xml

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.PHONY = default deps build test start-mooc-backend clean start-database start-backoffice-frontend
22

3+
# Shell to use for running scripts
4+
SHELL := $(shell which bash)
35
IMAGE_NAME := codelytv/typescript-ddd-skeleton
46
SERVICE_NAME := app
57
MOOC_APP_NAME := mooc

cypress.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"video": false,
3+
"screenshotOnRunFailure": false,
4+
"testFiles": "**/*.cypress.*",
5+
"integrationFolder": "tests/apps",
6+
"fixturesFolder": "tests/utils/cypress/fixtures",
7+
"pluginsFile": "tests/utils/cypress/plugins/index.ts"
8+
}

package-lock.json

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

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"scripts": {
1414
"dev": "NODE_ENV=dev ts-node-dev --ignore-watch node_modules --inspect=0.0.0.0:9267 ./src/apps/mooc_backend/server.ts",
1515
"dev:backoffice:frontend": "NODE_ENV=dev ts-node-dev --ignore-watch node_modules ./src/apps/backoffice/frontend/server.ts",
16-
"test": "npm run test:unit && npm run test:features",
16+
"test": "npm run test:unit && npm run test:features && npm run cypress:run",
1717
"test:unit": "NODE_ENV=test jest",
1818
"test:features": "NODE_ENV=test cucumber-js -p default",
1919
"lint": "tslint src/**/*.ts{,x}",
@@ -22,7 +22,9 @@
2222
"build": "npm run build:clean && npm run build:tsc && npm run build:di",
2323
"build:tsc": "tsc -p tsconfig.prod.json",
2424
"build:di": "copy 'src/**/*.{json,yaml,html,png}' dist/src",
25-
"build:clean": "rm -r dist; exit 0"
25+
"build:clean": "rm -r dist; exit 0",
26+
"cypress:open": "NODE_ENV=test ts-node tests/utils/cypress/open",
27+
"cypress:run": "NODE_ENV=test ts-node tests/utils/cypress/run"
2628
},
2729
"dependencies": {
2830
"@types/bson": "^4.0.2",
@@ -46,6 +48,7 @@
4648
"copy": "^0.3.2",
4749
"errorhandler": "^1.5.1",
4850
"express": "^4.17.1",
51+
"express-promise-router": "^4.0.1",
4952
"express-validator": "^6.6.1",
5053
"glob": "^7.1.6",
5154
"helmet": "^4.1.1",
@@ -66,11 +69,12 @@
6669
"@types/cookie-parser": "^1.4.2",
6770
"@types/cookie-session": "^2.0.41",
6871
"@types/cucumber": "^6.0.1",
69-
"@types/faker": "^5.1.0",
72+
"@types/faker": "^5.1.2",
7073
"@types/jest": "^26.0.14",
7174
"@types/nunjucks": "^3.1.3",
7275
"@types/supertest": "^2.0.10",
7376
"cucumber": "^6.0.5",
77+
"cypress": "^5.2.0",
7478
"faker": "^5.1.0",
7579
"husky": "^4.3.0",
7680
"jest": "^26.4.2",

src/Contexts/Mooc/Courses/application/CourseCreator.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ export class CourseCreator {
2222
}
2323

2424
async run({ courseId, courseName, courseDuration }: Params): Promise<void> {
25-
const course = Course.create(
26-
courseId,
27-
courseName,
28-
courseDuration
29-
);
25+
const course = Course.create(courseId, courseName, courseDuration);
3026

3127
await this.repository.save(course);
32-
this.eventBus.publish(course.pullDomainEvents());
28+
await this.eventBus.publish(course.pullDomainEvents());
3329
}
3430
}

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

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Contexts/Mooc/CoursesCounter/application/Increment/CoursesCounterIncrementer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class CoursesCounterIncrementer {
1414
counter.increment(courseId);
1515

1616
await this.repository.save(counter);
17-
this.bus.publish(counter.pullDomainEvents());
17+
await this.bus.publish(counter.pullDomainEvents());
1818
}
1919
}
2020

src/apps/backoffice/frontend/controllers/CoursesPostController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ export class CoursesPostController extends WebController {
1111

1212
static validator(): ValidationChain[] {
1313
return [
14-
body('id').isUUID(),
15-
body('name').isLength({ min: 1, max: 255 }),
16-
body('duration').isLength({ min: 4, max: 100 })
14+
body('id').isUUID().withMessage('Invalid course id'),
15+
body('name').isLength({ min: 1, max: 30 }).withMessage('Invalid name'),
16+
body('duration').isLength({ min: 4, max: 100 }).withMessage('Invalid duration')
1717
];
1818
}
1919

src/apps/backoffice/frontend/controllers/WebController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export abstract class WebController {
4040

4141
protected render(req: Request, res: Response, template: string, data: { [key: string]: any }) {
4242
const flash = this.feedFlash(req, data);
43-
res.render('pages/courses/courses', {
43+
res.render(template, {
4444
...data,
4545
...flash
4646
});

0 commit comments

Comments
 (0)