Skip to content

Commit fa86ca9

Browse files
committed
Merge branch 'part_five' into rabbitmq-eventbus
2 parents 34ab7c7 + d4748b0 commit fa86ca9

File tree

101 files changed

+318
-408
lines changed

Some content is hidden

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

101 files changed

+318
-408
lines changed
File renamed without changes.
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
import convict from 'convict';
22

3-
const convictConfig = convict({
3+
const backofficeConfig = convict({
44
env: {
55
doc: 'The application environment.',
66
format: ['production', 'development', 'staging', 'test'],
77
default: 'default',
88
env: 'NODE_ENV'
99
},
10-
mongo: {
11-
url: {
12-
doc: 'The Mongo connection URL',
13-
format: String,
14-
env: 'MONGO_URL',
15-
default: 'mongodb://localhost:27017/backoffice-backend-dev'
16-
}
17-
},
1810
elastic: {
1911
url: {
2012
doc: 'The Elastic connection URL',
@@ -25,6 +17,6 @@ const convictConfig = convict({
2517
}
2618
});
2719

28-
convictConfig.loadFile([__dirname + '/default.json', __dirname + '/' + convictConfig.get('env') + '.json']);
20+
backofficeConfig.loadFile([__dirname + '/default.json', __dirname + '/' + backofficeConfig.get('env') + '.json']);
2921

30-
export default convictConfig;
22+
export default backofficeConfig;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"elastic": {
3+
"url": "http://elasticsearch:9200"
4+
}
5+
}
File renamed without changes.
File renamed without changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import config from '../config';
2+
import ElasticConfig from '../../../../Shared/infrastructure/persistence/elasticsearch/ElasticConfig';
3+
4+
export class BackofficeElasticConfigFactory {
5+
static createConfig(): ElasticConfig {
6+
return {
7+
url: config.get('elastic.url')
8+
};
9+
}
10+
}

src/Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeMongoConfigFactory.ts

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

src/Contexts/Backoffice/Courses/infrastructure/persistence/ElasticBackofficeCourseRepository.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { ElasticRepository } from '../../../../Shared/infrastructure/persistence
22
import { BackofficeCourse } from '../../domain/BackofficeCourse';
33
import { BackofficeCourseRepository } from '../../domain/BackofficeCourseRepository';
44

5-
type ElasticBackofficeCourseDocument = { _source: { id: string; duration: string; name: string } };
6-
75
export class ElasticBackofficeCourseRepository
86
extends ElasticRepository<BackofficeCourse>
97
implements BackofficeCourseRepository {
@@ -12,23 +10,10 @@ export class ElasticBackofficeCourseRepository
1210
}
1311

1412
async searchAll(): Promise<BackofficeCourse[]> {
15-
const client = await this.client();
16-
17-
const response = await client.search({
18-
index: this.moduleName(),
19-
body: {
20-
query: {
21-
match_all: {}
22-
}
23-
}
24-
});
25-
26-
return response.body.hits.hits.map((hit: ElasticBackofficeCourseDocument) =>
27-
BackofficeCourse.fromPrimitives({ ...hit._source })
28-
);
13+
return this.searchAllInElastic(BackofficeCourse.fromPrimitives);
2914
}
3015

3116
async save(course: BackofficeCourse): Promise<void> {
32-
return this.persist(this.moduleName(), course);
17+
return this.persist(course);
3318
}
3419
}

src/Contexts/Backoffice/Courses/infrastructure/persistence/MongoBackofficeCourseRepository.ts

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export class MongoCourseRepository extends MongoRepository<Course> implements Co
1111

1212
public async search(id: CourseId): Promise<Nullable<Course>> {
1313
const collection = await this.collection();
14-
1514
const document = await collection.findOne({ _id: id.value });
1615

1716
return document ? Course.fromPrimitives({ ...document, id: id.value }) : null;

0 commit comments

Comments
 (0)