Skip to content

Commit

Permalink
Merge pull request #31 from otasoft/feat-#18/add-aliases
Browse files Browse the repository at this point in the history
Feat #18/add aliases
  • Loading branch information
Baroshem authored Feb 2, 2021
2 parents 30f05ad + f9d897c commit 07a7b0d
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 24 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@nestjs/typeorm": "^7.1.5",
"amqp-connection-manager": "^3.2.1",
"amqplib": "^0.6.0",
"module-alias": "^2.2.2",
"node-eventstore-client": "^0.2.18",
"node-nats-streaming": "^0.3.2",
"pg": "^8.5.1",
Expand Down Expand Up @@ -75,5 +76,11 @@
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
},
"_moduleAliases": {
"@infrastructure": "dist/item/infrastructure",
"@domain": "dist/item/domain",
"@application": "dist/item/application",
"@database": "dist/database"
}
}
2 changes: 1 addition & 1 deletion src/item/application/application.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import {
ItemReadRepository,
ItemWriteRepository,
} from '../infrastructure/repositories';
} from '@infrastructure/repositories';
import { CommandHandlers } from './commands/handlers';
import { ItemController } from './controllers';
import { QueryHandlers } from './queries/handlers';
Expand Down
8 changes: 4 additions & 4 deletions src/item/application/commands/handlers/create-item.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { CommandHandler, EventPublisher, ICommandHandler } from '@nestjs/cqrs';
import { InjectRepository } from '@nestjs/typeorm';
import { RpcException } from '@nestjs/microservices';

import { ItemEntity } from '../../../infrastructure/entities';
import { ItemRepository } from '../../../domain/repositories';
import { ItemWriteRepository } from '../../../infrastructure/repositories';
import { ItemEntity } from '@infrastructure/entities';
import { ItemRepository } from '@domain/repositories';
import { ItemWriteRepository } from '@infrastructure/repositories';
import { validateDbError } from '@database/helpers';
import { CreateItemCommand } from '../impl';
import { validateDbError } from '../../../../database/helpers';

@CommandHandler(CreateItemCommand)
export class CreateItemHandler implements ICommandHandler<CreateItemCommand> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { CommandHandler, EventPublisher, ICommandHandler } from '@nestjs/cqrs';
import { InjectRepository } from '@nestjs/typeorm';
import { RpcException } from '@nestjs/microservices';

import { ItemEntity } from '@infrastructure/entities';
import { ItemRepository } from '@domain/repositories';
import { ItemWriteRepository } from '@infrastructure/repositories';
import { validateDbError } from '@database/helpers';
import { DeleteItemByIdCommand } from '../impl';
import { ItemEntity } from '../../../infrastructure/entities';
import { ItemRepository } from '../../../domain/repositories';
import { ItemWriteRepository } from '../../../infrastructure/repositories';
import { validateDbError } from '../../../../database/helpers';

@CommandHandler(DeleteItemByIdCommand)
export class DeleteItemByIdHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommandHandler, EventPublisher, ICommandHandler } from '@nestjs/cqrs';

import { ItemRepository } from '../../../domain/repositories';
import { ItemRepository } from '@domain/repositories';
import { NotifyItemOwnerCommand } from '../impl';

@CommandHandler(NotifyItemOwnerCommand)
Expand Down
8 changes: 4 additions & 4 deletions src/item/application/commands/handlers/update-item.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { CommandHandler, EventPublisher, ICommandHandler } from '@nestjs/cqrs';
import { InjectRepository } from '@nestjs/typeorm';
import { RpcException } from '@nestjs/microservices';

import { ItemEntity } from '@infrastructure/entities';
import { ItemRepository } from '@domain/repositories';
import { ItemWriteRepository } from '@infrastructure/repositories';
import { validateDbError } from '@database/helpers';
import { UpdateItemCommand } from '../impl';
import { ItemEntity } from '../../../infrastructure/entities';
import { ItemRepository } from '../../../domain/repositories';
import { ItemWriteRepository } from '../../../infrastructure/repositories';
import { validateDbError } from '../../../../database/helpers';

@CommandHandler(UpdateItemCommand)
export class UpdateItemHandler implements ICommandHandler<UpdateItemCommand> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemEventType } from '../../../domain/types';
import { ItemEventType } from '@domain/types';

export class NotifyItemOwnerCommand {
constructor(public readonly event: ItemEventType) {}
Expand Down
2 changes: 1 addition & 1 deletion src/item/application/controllers/item.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';

import { ItemEntity } from '@infrastructure/entities';
import { CreateItemDto, GetItemsDto, UpdateItemDto } from '../dtos';
import { ItemEntity } from '../../infrastructure/entities';
import { ItemService } from '../services';

@Controller('item')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { QueryHandler, IQueryHandler } from '@nestjs/cqrs';
import { InjectRepository } from '@nestjs/typeorm';
import { RpcException } from '@nestjs/microservices';

import { ItemEntity } from '@infrastructure/entities';
import { ItemReadRepository } from '@infrastructure/repositories';
import { GetItemByIdQuery } from '../impl';
import { ItemEntity } from '../../../infrastructure/entities';
import { ItemReadRepository } from '../../../infrastructure/repositories';

@QueryHandler(GetItemByIdQuery)
export class GetItemByIdHandler implements IQueryHandler<GetItemByIdQuery> {
Expand Down
4 changes: 2 additions & 2 deletions src/item/application/queries/handlers/get-items.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { InjectRepository } from '@nestjs/typeorm';
import { RpcException } from '@nestjs/microservices';

import { ItemEntity } from '../../../infrastructure/entities';
import { ItemReadRepository } from '../../../infrastructure/repositories';
import { ItemEntity } from '@infrastructure/entities';
import { ItemReadRepository } from '@infrastructure/repositories';
import { GetItemsQuery } from '../impl';

@QueryHandler(GetItemsQuery)
Expand Down
2 changes: 1 addition & 1 deletion src/item/application/services/item.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { CommandBus, QueryBus } from '@nestjs/cqrs';

import { ItemEntity } from '../../infrastructure/entities';
import { ItemEntity } from '@infrastructure/entities';
import {
CreateItemCommand,
DeleteItemByIdCommand,
Expand Down
2 changes: 1 addition & 1 deletion src/item/domain/models/item.model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AggregateRoot } from '@nestjs/cqrs';

import { CreateItemDto, UpdateItemDto } from '../../application/dtos';
import { CreateItemDto, UpdateItemDto } from '@application/dtos';
import {
ItemCreatedEvent,
ItemDeletedEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/item/domain/sagas/item.sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ICommand, ofType, Saga } from '@nestjs/cqrs';
import { Observable } from 'rxjs';
import { delay, map } from 'rxjs/operators';

import { NotifyItemOwnerCommand } from '../../application/commands/impl';
import { NotifyItemOwnerCommand } from '@application/commands/impl';
import {
ItemCreatedEvent,
ItemUpdatedEvent,
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
"incremental": true,
"moduleResolution": "node",
"paths": {
"@infrastructure/*": ["src/item/infrastructure/*"],
"@domain/*": ["src/item/domain/*"],
"@application/*": ["src/item/application/*"],
"@database/*": ["src/database/*"],
}
}
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4575,6 +4575,11 @@ mkdirp@^0.5.1:
dependencies:
minimist "^1.2.5"

module-alias@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0"
integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==

moment-timezone@^0.5.x:
version "0.5.32"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.32.tgz#db7677cc3cc680fd30303ebd90b0da1ca0dfecc2"
Expand Down

0 comments on commit 07a7b0d

Please sign in to comment.