Skip to content

Commit e376d6d

Browse files
authored
Merge pull request #27 from maick05/development
Development
2 parents 87a9efd + a757cff commit e376d6d

File tree

166 files changed

+7192
-346
lines changed

Some content is hidden

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

166 files changed

+7192
-346
lines changed

CHANGELOG.MD

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ All notable changes to this project will be documented in this file.
4545
- Optimize Neighborhoods by State
4646
- Sort Collections result
4747

48-
## [0.0.6] - 2022-08-03
48+
## [0.0.6] - 2022-08-04
4949

5050
### Added
5151

@@ -54,3 +54,15 @@ All notable changes to this project will be documented in this file.
5454
- Async Seed Neighborhoods By State Job
5555
- Fix regex filter in mongodb query
5656
- Secrets and docker container process in GitHub Actions
57+
58+
## [0.0.7] - 2022-08-21
59+
60+
### Added
61+
62+
- LogExecution Schema
63+
- LogAction Schema
64+
- Route Request Resolution
65+
- Route Regions By Country
66+
- Route Seed Neighborhoods By Country
67+
- Seed Regions By Puppeteer
68+
- Seed Neighborhoods By State Queue

config/yaml/values.yaml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@ repository:
22
neighborhoods:
33
guia-mais:
44
url: 'https://www.guiamais.com.br/bairros'
5+
regions:
6+
citypopulation:
7+
url: 'https://www.citypopulation.de'
58
database:
69
mongodb:
710
connection: 'mongodb+srv://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_URL_CONNECTION}${MONGODB_DATABASE_NAME}${MONGODB_SUFIX_PARAMS}'
811
microservices:
912
rabbitmq:
1013
url: 'amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@${RABBITMQ_HOST}/${RABBITMQ_VHOST}'
1114
queue:
12-
connection: 'places-queue'
13-
messages: 'seed-messages'
14-
success: 'seed-success'
15-
error: 'seed-error'
15+
connection: 'places-connection'
16+
seed:
17+
neighborhoods:
18+
by:
19+
city:
20+
process: 'seed-neighborhoods-by-city-process'
21+
success: 'seed-neighborhoods-by-city-success'
22+
error: 'seed-neighborhoods-by-city-error'
23+
state:
24+
process: 'seed-neighborhoods-by-state-process'
1625
exchange:
1726
seed:
1827
neighborhoods:
@@ -21,8 +30,17 @@ microservices:
2130
process: 'seed-neighborhoods-by-city-process'
2231
success: 'seed-neighborhoods-by-city-success'
2332
error: 'seed-neighborhoods-by-city-error'
33+
state:
34+
process: 'seed-neighborhoods-by-state-process'
35+
channel:
36+
prefetch-count: 1
37+
seed:
38+
neighborhoods:
39+
by:
40+
city: 'channel-seed-neighborhoods-by-city'
41+
state: 'channel-seed-neighborhoods-by-state'
2442
api:
2543
port: 3000
2644
doc:
27-
version: 0.0.6
45+
version: 0.0.7
2846
name: 'places'

src/app.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import { CountriesModule } from './microservice/adapter/module/countries.module'
99
import { ExtensionsModule } from './microservice/adapter/helper/extensions/exensions.module';
1010
import { CustomPuppeteerModule } from './microservice/adapter/helper/modules/custom-puppeteer.module';
1111
import { NeighborhoodsModule } from './microservice/adapter/module/neighborhoods.module';
12-
import { SeedModule } from './microservice/adapter/module/seed.module';
12+
import { SeedNeighborhoodsModule } from './microservice/adapter/module/seed/seed-neighborhoods.module';
1313
import { StatesModule } from './microservice/adapter/module/states.module';
14+
import { ResolutionsModule } from './microservice/adapter/module/resolution.module';
15+
import { SeedRegionsModule } from './microservice/adapter/module/seed/seed-regions.module';
1416

1517
@Module({
1618
imports: [
@@ -31,7 +33,9 @@ import { StatesModule } from './microservice/adapter/module/states.module';
3133
CitiesModule,
3234
StatesModule,
3335
CountriesModule,
34-
SeedModule
36+
SeedNeighborhoodsModule,
37+
ResolutionsModule,
38+
SeedRegionsModule
3539
],
3640
controllers: [],
3741
providers: [
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export enum EnumConfigAMQP {
22
QUEUE = 'microservices.rabbitmq.queue',
33
EVENT = 'microservices.rabbitmq.event',
4-
EXCHANGE = 'microservices.rabbitmq.exchange'
4+
EXCHANGE = 'microservices.rabbitmq.exchange',
5+
CHANNEL = 'microservices.rabbitmq.channel'
56
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ConfigHelper } from '../../microservice/adapter/helper/config/config.helper';
2+
import { EnumConfigAMQP } from './enum/enum-config-amqp.enumerator';
3+
4+
export const CHANNEL_SEED_NEIGHBORHOODS_BY_CITY = ConfigHelper.getConfig(
5+
'seed.neighborhoods.by.city',
6+
EnumConfigAMQP.CHANNEL
7+
);
8+
9+
export const CHANNEL_SEED_NEIGHBORHOODS_BY_STATE = ConfigHelper.getConfig(
10+
'seed.neighborhoods.by.state',
11+
EnumConfigAMQP.CHANNEL
12+
);
13+
14+
const DEFAULT_CHANNEL = CHANNEL_SEED_NEIGHBORHOODS_BY_CITY;
15+
16+
const prefetchCount = ConfigHelper.getConfig(
17+
'prefetch-count',
18+
EnumConfigAMQP.CHANNEL
19+
);
20+
21+
export const channelsConfig = mountChannels([
22+
CHANNEL_SEED_NEIGHBORHOODS_BY_CITY,
23+
CHANNEL_SEED_NEIGHBORHOODS_BY_STATE
24+
]);
25+
26+
function mountChannels(arr) {
27+
const channels = {};
28+
arr.forEach((item) => {
29+
channels[item] = {
30+
prefetchCount,
31+
default: item === DEFAULT_CHANNEL
32+
};
33+
});
34+
return channels;
35+
}

src/config/amqp/rabbitmq-exchanges.config.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
import { ConfigHelper } from '../../microservice/adapter/helper/config/config.helper';
22
import { EnumConfigAMQP } from './enum/enum-config-amqp.enumerator';
33

4-
export const seedByCityProcess = ConfigHelper.getConfig(
4+
export const seedNeighborhoodsByCityProcess = ConfigHelper.getConfig(
55
'seed.neighborhoods.by.city.process',
66
EnumConfigAMQP.EXCHANGE
77
);
88

9-
export const seedByCitySuccess = ConfigHelper.getConfig(
9+
export const seedNeighborhoodsByCitySuccess = ConfigHelper.getConfig(
1010
'seed.neighborhoods.by.city.success',
1111
EnumConfigAMQP.EXCHANGE
1212
);
1313

14-
export const seedByCityError = ConfigHelper.getConfig(
14+
export const seedNeighborhoodsByCityError = ConfigHelper.getConfig(
1515
'seed.neighborhoods.by.city.error',
1616
EnumConfigAMQP.EXCHANGE
1717
);
1818

19+
export const seedNeighborhoodsByStateProcess = ConfigHelper.getConfig(
20+
'seed.neighborhoods.by.state.process',
21+
EnumConfigAMQP.EXCHANGE
22+
);
23+
1924
const type = 'topic';
2025
export const arrExchanges = mountExchanges([
21-
seedByCitySuccess,
22-
seedByCityError,
23-
seedByCityProcess
26+
seedNeighborhoodsByCitySuccess,
27+
seedNeighborhoodsByCityError,
28+
seedNeighborhoodsByCityProcess,
29+
seedNeighborhoodsByStateProcess
2430
]);
2531

2632
function mountExchanges(arr) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ConfigHelper } from '../../microservice/adapter/helper/config/config.helper';
2+
import { EnumConfigAMQP } from './enum/enum-config-amqp.enumerator';
3+
4+
export const QUEUE_SEED_MESSAGE_NEIGHBORHOODS_BY_CITY = ConfigHelper.getConfig(
5+
'seed.neighborhoods.by.city.process',
6+
EnumConfigAMQP.QUEUE
7+
);
8+
9+
export const QUEUE_SEED_SUCCESS_NEIGHBORHOODS_BY_CITY = ConfigHelper.getConfig(
10+
'seed.neighborhoods.by.city.success',
11+
EnumConfigAMQP.QUEUE
12+
);
13+
14+
export const QUEUE_SEED_ERROR_NEIGHBORHOODS_BY_CITY = ConfigHelper.getConfig(
15+
'seed.neighborhoods.by.city.error',
16+
EnumConfigAMQP.QUEUE
17+
);
18+
19+
export const QUEUE_SEED_MESSAGE_NEIGHBORHOODS_BY_STATE = ConfigHelper.getConfig(
20+
'seed.neighborhoods.by.state.process',
21+
EnumConfigAMQP.QUEUE
22+
);
Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
1-
import { ConfigHelper } from '../../microservice/adapter/helper/config/config.helper';
2-
import { EnumConfigAMQP } from './enum/enum-config-amqp.enumerator';
31
import {
4-
seedByCityError,
5-
seedByCityProcess,
6-
seedByCitySuccess
2+
CHANNEL_SEED_NEIGHBORHOODS_BY_CITY,
3+
CHANNEL_SEED_NEIGHBORHOODS_BY_STATE
4+
} from './rabbitmq-channels.config';
5+
import {
6+
seedNeighborhoodsByCityError,
7+
seedNeighborhoodsByCityProcess,
8+
seedNeighborhoodsByCitySuccess,
9+
seedNeighborhoodsByStateProcess
710
} from './rabbitmq-exchanges.config';
8-
9-
const QUEUE_SEED_MESSAGES = ConfigHelper.getConfig(
10-
'messages',
11-
EnumConfigAMQP.QUEUE
12-
);
13-
14-
const QUEUE_SEED_SUCCESS = ConfigHelper.getConfig(
15-
'success',
16-
EnumConfigAMQP.QUEUE
17-
);
18-
19-
const QUEUE_SEED_ERROR = ConfigHelper.getConfig('error', EnumConfigAMQP.QUEUE);
11+
import {
12+
QUEUE_SEED_ERROR_NEIGHBORHOODS_BY_CITY,
13+
QUEUE_SEED_MESSAGE_NEIGHBORHOODS_BY_CITY,
14+
QUEUE_SEED_MESSAGE_NEIGHBORHOODS_BY_STATE,
15+
QUEUE_SEED_SUCCESS_NEIGHBORHOODS_BY_CITY
16+
} from './rabbitmq-queues.config';
2017

2118
/* EXPORT */
2219
export const routeKeySub = 'sub-1';
2320

2421
export const subscribeSeedByCityProcess = {
25-
exchange: seedByCityProcess,
22+
exchange: seedNeighborhoodsByCityProcess,
2623
routingKey: routeKeySub,
27-
queue: QUEUE_SEED_MESSAGES,
24+
queue: QUEUE_SEED_MESSAGE_NEIGHBORHOODS_BY_CITY,
2825
queueOptions: {
29-
channel: 'channel-1'
26+
channel: CHANNEL_SEED_NEIGHBORHOODS_BY_CITY
3027
}
3128
};
3229

3330
export const subscribeSeedByCitySuccess = {
34-
exchange: seedByCitySuccess,
31+
exchange: seedNeighborhoodsByCitySuccess,
3532
routingKey: routeKeySub,
36-
queue: QUEUE_SEED_SUCCESS
33+
queue: QUEUE_SEED_SUCCESS_NEIGHBORHOODS_BY_CITY
3734
};
3835

3936
export const subscribeSeedByCityError = {
40-
exchange: seedByCityError,
37+
exchange: seedNeighborhoodsByCityError,
4138
routingKey: routeKeySub,
42-
queue: QUEUE_SEED_ERROR
39+
queue: QUEUE_SEED_ERROR_NEIGHBORHOODS_BY_CITY
40+
};
41+
42+
export const subscribeSeedByStateProcess = {
43+
exchange: seedNeighborhoodsByStateProcess,
44+
routingKey: routeKeySub,
45+
queue: QUEUE_SEED_MESSAGE_NEIGHBORHOODS_BY_STATE,
46+
queueOptions: {
47+
channel: CHANNEL_SEED_NEIGHBORHOODS_BY_STATE
48+
}
4349
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { HttpStatus } from '@nestjs/common';
2+
import { CustomErrorException } from './custom-error.exception';
3+
4+
export class ResolutionException extends CustomErrorException {
5+
constructor(
6+
message: string,
7+
status: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR
8+
) {
9+
super(message, status, 6);
10+
}
11+
}

src/microservice/adapter/controller/neighborhoods.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Controller, Get, HttpStatus, Param } from '@nestjs/common';
22
import { GetNeighborhoodsByStateService } from '../../domain/service/neighborhoods/get/get-neighborhoods-by-state.service';
33
import { NestResponse } from '../../../core/http/nest-response';
44
import { AbstractController } from '../../domain/controller/abstract-controller';
5-
import { GetNeighborhoodsByCityService } from '../../domain/service/neighborhoods/get/get-neighborhoods-by-city.service';
65
import { SearchNeighborhoodsDTO } from '../../domain/model/search/neighborhoods/search-neighborhoods-dto.model';
76
import {
87
ApiOkResponse,
@@ -12,12 +11,13 @@ import {
1211
} from '@nestjs/swagger';
1312
import { NeighborhoodByCity } from '../../domain/model/neighborhoods/neighborhood-by-city.model';
1413
import { NeighborhoodsByState } from '../../domain/model/neighborhoods/neighborhoods-by-state.model';
14+
import { NeighborhoodsByCityService } from '../../domain/service/neighborhoods/neighborhoods-by-city.service';
1515

1616
@ApiTags('neighborhoods')
1717
@Controller('neighborhoods')
1818
export class NeighborhoodsController extends AbstractController {
1919
constructor(
20-
private readonly getNeighborhoodsByCityService: GetNeighborhoodsByCityService,
20+
private readonly getNeighborhoodsByCityService: NeighborhoodsByCityService,
2121
private readonly getNeighborhoodsByStateService: GetNeighborhoodsByStateService
2222
) {
2323
super();
@@ -55,7 +55,7 @@ export class NeighborhoodsController extends AbstractController {
5555
): Promise<NestResponse> {
5656
return this.buildResponse(
5757
HttpStatus.OK,
58-
await this.getNeighborhoodsByCityService.getNeighborhoodsByCity(params)
58+
await this.getNeighborhoodsByCityService.getFindAndSeedElements(params)
5959
);
6060
}
6161

0 commit comments

Comments
 (0)