├── services └── monolith │ ├── src │ ├── Core │ │ ├── NestJs │ │ │ ├── index.ts │ │ │ └── intermediateModule.ts │ │ ├── Outbox │ │ │ ├── Testing │ │ │ │ ├── index.ts │ │ │ │ └── TestOutbox.ts │ │ │ ├── NestJs │ │ │ │ ├── constants.ts │ │ │ │ ├── index.ts │ │ │ │ ├── RegisterOutboxWorker.ts │ │ │ │ └── OutboxModule.ts │ │ │ ├── index.ts │ │ │ ├── Outbox.ts │ │ │ └── MikroOrm │ │ │ │ ├── index.ts │ │ │ │ ├── __tests__ │ │ │ │ ├── MikroOrmOutbox.test.ts │ │ │ │ └── MikroOrmOutboxWorker.test.ts │ │ │ │ ├── OutboxMessageEntity.ts │ │ │ │ ├── MikroOrmOutbox.ts │ │ │ │ └── MikroOrmOutboxWorker.ts │ │ ├── Auth │ │ │ ├── NestJs │ │ │ │ ├── constants.ts │ │ │ │ ├── types.ts │ │ │ │ ├── Decorators │ │ │ │ │ └── CurrentAccount.ts │ │ │ │ ├── AccountAuthModule.ts │ │ │ │ ├── Guards │ │ │ │ │ └── AccountGuard.ts │ │ │ │ └── __tests__ │ │ │ │ │ └── nest-integration.test.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ └── Testing │ │ │ │ └── createTestTokenFactory.ts │ │ ├── Testing │ │ │ ├── index.ts │ │ │ ├── waitMs.ts │ │ │ ├── TestLogger.ts │ │ │ └── runMikroOrmMigrations.ts │ │ ├── Logger │ │ │ ├── index.ts │ │ │ ├── Logger.ts │ │ │ ├── NestJs │ │ │ │ ├── nestJsLoggerProvider.ts │ │ │ │ ├── NestJsLoggerAdapter.ts │ │ │ │ └── __tests__ │ │ │ │ │ └── NestJsLoggerAdapter.test.ts │ │ │ ├── pinoFactory.ts │ │ │ ├── PinoLogger.ts │ │ │ └── __tests__ │ │ │ │ └── pino.test.ts │ │ ├── EventBus │ │ │ ├── index.ts │ │ │ ├── Event.ts │ │ │ ├── EventBus.ts │ │ │ ├── NestJs │ │ │ │ └── nestJsInMemoryEventBusProvider.ts │ │ │ ├── EventBusCompositeCoordinator.ts │ │ │ ├── __tests__ │ │ │ │ ├── EventBusCompositeCoordinator.test.ts │ │ │ │ └── EventBus.test.ts │ │ │ └── InMemoryEventBus.ts │ │ └── Fp │ │ │ ├── Either.ts │ │ │ └── __tests__ │ │ │ └── Either.test.ts │ ├── AccountContext │ │ ├── __tests__ │ │ │ ├── utils │ │ │ │ ├── index.ts │ │ │ │ └── createTestConfig.ts │ │ │ ├── Account.test.ts │ │ │ └── integration │ │ │ │ └── index.test.ts │ │ ├── Events │ │ │ ├── index.ts │ │ │ ├── AccountCreatedEvent.ts │ │ │ └── AccountSuspendedEvent.ts │ │ ├── index.ts │ │ ├── Services │ │ │ ├── Commands │ │ │ │ └── SuspendAccountCommand.ts │ │ │ ├── ConfirmAccountService.ts │ │ │ ├── SuspendAccountService.ts │ │ │ ├── CreateAccountService.ts │ │ │ ├── CreateAuthTokenService.ts │ │ │ └── __tests__ │ │ │ │ ├── SuspendAccountService.test.ts │ │ │ │ └── CreateAuthTokenService.test.ts │ │ ├── Dto │ │ │ ├── CreateAccountDto.ts │ │ │ └── CreateAuthTokenDto.ts │ │ ├── Repositories │ │ │ ├── AccountRepository.ts │ │ │ ├── __tests__ │ │ │ │ └── InMemoryAccountRepository.test.ts │ │ │ ├── InMemoryAccountRepository.ts │ │ │ └── SqliteAccountRepository.ts │ │ ├── AccountContextGateway.ts │ │ ├── Controllers │ │ │ ├── AuthController.ts │ │ │ ├── AccountController.ts │ │ │ └── __tests__ │ │ │ │ └── AuthController.test.ts │ │ ├── Configs │ │ │ └── AccountContextConfig.ts │ │ ├── EventHandlers │ │ │ ├── SendAccountCreatedEmail.ts │ │ │ └── __tests__ │ │ │ │ └── SendAccountCreatedEmail.test.ts │ │ ├── Entities │ │ │ └── Account.ts │ │ └── AccountContextModule.ts │ ├── AuctionContext │ │ ├── __tests__ │ │ │ ├── utils │ │ │ │ ├── index.ts │ │ │ │ ├── createTestConfig.ts │ │ │ │ └── createTestToken.ts │ │ │ └── integration │ │ │ │ └── index.test.ts │ │ ├── Controllers │ │ │ ├── Dto │ │ │ │ ├── PlaceAuctionBidDto.ts │ │ │ │ └── CreateAuctionDto.ts │ │ │ └── AuctionController.ts │ │ ├── Repositories │ │ │ ├── AuctionRepository.ts │ │ │ ├── SqliteAuctionRepository.ts │ │ │ └── InMemoryAuctionRepository.ts │ │ ├── Services │ │ │ ├── Commands │ │ │ │ ├── PlaceAuctionBidCommand.ts │ │ │ │ └── CreateAuctionCommand.ts │ │ │ ├── CreateAuctionService.ts │ │ │ ├── PlaceAuctionBidService.ts │ │ │ └── __tests__ │ │ │ │ └── PlaceAuctionBidService.test.ts │ │ ├── Configs │ │ │ └── AuctionContextConfig.ts │ │ ├── Entities │ │ │ ├── Bid.ts │ │ │ ├── __tests__ │ │ │ │ └── Auction.test.ts │ │ │ └── Auction.ts │ │ ├── EventHandlers │ │ │ ├── AccountSuspendedEventHandler.ts │ │ │ └── __tests__ │ │ │ │ └── AccountSuspendedEventHandler.test.ts │ │ └── AuctionContextModule.ts │ └── index.ts │ ├── .env.example │ ├── .eslintrc.js │ ├── tsconfig.json │ ├── jest.config.js │ └── package.json ├── packages ├── zod-dto │ ├── .npmignore │ ├── src │ │ ├── OpenApi │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── __tests__ │ │ │ │ ├── openApiBuilder.test.ts │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── zodTypeToOpenApi.test.ts.snap │ │ │ │ └── zodTypeToOpenApi.test.ts │ │ │ ├── patchNestjsSwagger.ts │ │ │ ├── openApiBuilder.ts │ │ │ └── zodTypeToOpenApi.ts │ │ ├── index.ts │ │ ├── __tests__ │ │ │ └── createZodDto.test.ts │ │ ├── ZodValidationPipe.ts │ │ └── createZodDto.ts │ ├── .eslintrc.js │ ├── tsconfig.json │ ├── jest.config.js │ ├── package.json │ └── README.md ├── tsconfig │ ├── tsconfig.json │ └── package.json └── eslint-config │ ├── patch-eslint.js │ └── package.json ├── common ├── config │ └── rush │ │ ├── .npmrc │ │ ├── experiments.json │ │ ├── common-versions.json │ │ ├── version-policies.json │ │ └── command-line.json └── scripts │ ├── install-run-rushx.js │ └── install-run-rush.js ├── .run └── Start Monolith.run.xml ├── .travis.yml ├── README.md ├── .gitattributes ├── package.json ├── .gitignore ├── .github └── workflows │ └── feature-branch-test.yml └── rush.json /services/monolith/src/Core/NestJs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './intermediateModule'; 2 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/Testing/index.ts: -------------------------------------------------------------------------------- 1 | export * from './TestOutbox'; 2 | -------------------------------------------------------------------------------- /packages/zod-dto/.npmignore: -------------------------------------------------------------------------------- 1 | .git 2 | .rush 3 | src 4 | jest.config.js 5 | tsconfig.json 6 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/NestJs/constants.ts: -------------------------------------------------------------------------------- 1 | export const OUTBOX = 'OUTBOX'; 2 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/__tests__/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './createTestConfig'; 2 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Auth/NestJs/constants.ts: -------------------------------------------------------------------------------- 1 | export const AUTH_MODULE_CONFIG = 'AUTH_MODULE_CONFIG'; 2 | -------------------------------------------------------------------------------- /services/monolith/.env.example: -------------------------------------------------------------------------------- 1 | # The secret used to sign JWT tokens 2 | JWT_SECRET_KEY=testKey-testKey-testKey-testKey- 3 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/index.ts: -------------------------------------------------------------------------------- 1 | export * from './MikroOrm'; 2 | export * from './NestJs'; 3 | export * from './Outbox'; 4 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Events/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AccountCreatedEvent'; 2 | export * from './AccountSuspendedEvent'; 3 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/__tests__/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './createTestConfig'; 2 | export * from './createTestToken'; 3 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Testing/index.ts: -------------------------------------------------------------------------------- 1 | export * from './TestLogger'; 2 | export * from './runMikroOrmMigrations'; 3 | export * from './waitMs'; 4 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AccountContextModule'; 2 | export { AccountContextGateway } from './AccountContextGateway'; 3 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Testing/waitMs.ts: -------------------------------------------------------------------------------- 1 | export const waitMs = (ms: number): Promise => 2 | new Promise(resolve => setTimeout(resolve, ms)); 3 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/NestJs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './OutboxModule'; 2 | export * from './RegisterOutboxWorker'; 3 | export * from './constants'; 4 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/Outbox.ts: -------------------------------------------------------------------------------- 1 | import { Event } from '../EventBus'; 2 | 3 | export interface Outbox { 4 | send(event: Event): Promise; 5 | } 6 | -------------------------------------------------------------------------------- /packages/zod-dto/src/OpenApi/index.ts: -------------------------------------------------------------------------------- 1 | export { patchNestjsSwagger } from './patchNestjsSwagger'; 2 | export { buildOpenApi, OpenApiBuilder } from './openApiBuilder'; 3 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/MikroOrm/index.ts: -------------------------------------------------------------------------------- 1 | export * from './MikroOrmOutbox'; 2 | export * from './MikroOrmOutboxWorker'; 3 | export * from './OutboxMessageEntity'; 4 | -------------------------------------------------------------------------------- /packages/zod-dto/src/index.ts: -------------------------------------------------------------------------------- 1 | export { ZodValidationPipe } from './ZodValidationPipe'; 2 | export { createZodDto, ZodDtoStatic } from './createZodDto'; 3 | export * from './OpenApi'; 4 | -------------------------------------------------------------------------------- /packages/zod-dto/src/OpenApi/types.ts: -------------------------------------------------------------------------------- 1 | export interface OpenApiBuilderProperties { 2 | example?: unknown; 3 | description?: string; 4 | format?: string; 5 | type?: string; 6 | } 7 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './NestJs/Decorators/CurrentAccount'; 2 | export * from './NestJs/Guards/AccountGuard'; 3 | export * from './NestJs/AccountAuthModule'; 4 | -------------------------------------------------------------------------------- /packages/zod-dto/.eslintrc.js: -------------------------------------------------------------------------------- 1 | require('@abitia/eslint-config/patch-eslint'); 2 | 3 | module.exports = { 4 | root: true, 5 | extends: [ 6 | '@abitia/eslint-config' 7 | ] 8 | }; 9 | -------------------------------------------------------------------------------- /services/monolith/.eslintrc.js: -------------------------------------------------------------------------------- 1 | require('@abitia/eslint-config/patch-eslint'); 2 | 3 | module.exports = { 4 | root: true, 5 | extends: [ 6 | '@abitia/eslint-config' 7 | ] 8 | }; 9 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Logger/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Logger'; 2 | export * from './NestJs/NestJsLoggerAdapter'; 3 | export * from './NestJs/nestJsLoggerProvider'; 4 | export * from './PinoLogger'; 5 | -------------------------------------------------------------------------------- /services/monolith/src/Core/EventBus/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Event'; 2 | export * from './EventBus'; 3 | export * from './EventBusCompositeCoordinator'; 4 | export * from './NestJs/nestJsInMemoryEventBusProvider'; 5 | -------------------------------------------------------------------------------- /packages/tsconfig/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": [ 4 | "es2020" 5 | ], 6 | "module": "commonjs", 7 | "target": "es2019", 8 | "strictNullChecks": true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Auth/NestJs/types.ts: -------------------------------------------------------------------------------- 1 | import { Request } from 'express'; 2 | 3 | import { TokenPayload } from '../types'; 4 | 5 | export type RequestWithAccount = Request & { 6 | account: TokenPayload, 7 | } 8 | -------------------------------------------------------------------------------- /packages/tsconfig/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@abitia/tsconfig", 3 | "version": "1.0.0", 4 | "description": "TypeScript tsconfig.json for @abitia", 5 | "scripts": { 6 | "build": "exit 0" 7 | }, 8 | "author": "Jakub Kisielewski", 9 | "license": "MIT" 10 | } 11 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Testing/TestLogger.ts: -------------------------------------------------------------------------------- 1 | import { Logger } from '../Logger'; 2 | 3 | export class TestLogger implements Logger { 4 | public debug = jest.fn(); 5 | 6 | public error = jest.fn(); 7 | 8 | public info = jest.fn(); 9 | 10 | public warn = jest.fn(); 11 | } 12 | -------------------------------------------------------------------------------- /services/monolith/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@abitia/tsconfig", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "rootDir": "./src", 6 | "experimentalDecorators": true, 7 | "emitDecoratorMetadata": true 8 | }, 9 | "include": [ 10 | "src" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Auth/types.ts: -------------------------------------------------------------------------------- 1 | import * as z from 'zod'; 2 | 3 | export interface AuthModuleConfig { 4 | jwtSecret: string; 5 | } 6 | 7 | export const tokenPayloadSchema = z.object({ 8 | accountId: z.string().uuid(), 9 | }); 10 | 11 | export type TokenPayload = z.infer; 12 | -------------------------------------------------------------------------------- /packages/eslint-config/patch-eslint.js: -------------------------------------------------------------------------------- 1 | /* 2 | https://github.com/eslint/eslint/issues/3458#issuecomment-516716165 3 | 4 | We need to patch ESLint plugin loading, so this should be added to the top of .eslintrc.js: 5 | require("@abitia/eslint/patch-eslint"); 6 | */ 7 | 8 | require('@rushstack/eslint-patch/modern-module-resolution'); 9 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/Controllers/Dto/PlaceAuctionBidDto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const placeAuctionBidDtoSchema = z.object({ 5 | price: z.number().int(), 6 | }); 7 | 8 | export class PlaceAuctionBidDto extends createZodDto(placeAuctionBidDtoSchema) {} 9 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/__tests__/utils/createTestConfig.ts: -------------------------------------------------------------------------------- 1 | import { AccountContextConfig } from '../../Configs/AccountContextConfig'; 2 | 3 | export const createTestConfig = (): AccountContextConfig => { 4 | return AccountContextConfig.create({ 5 | jwtSecretKey: 'testKey-testKey-testKey-testKey-', 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/__tests__/utils/createTestConfig.ts: -------------------------------------------------------------------------------- 1 | import { AuctionContextConfig } from '../../Configs/AuctionContextConfig'; 2 | 3 | export const createTestConfig = (): AuctionContextConfig => { 4 | return AuctionContextConfig.create({ 5 | jwtSecretKey: 'testKey-testKey-testKey-testKey-', 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Logger/Logger.ts: -------------------------------------------------------------------------------- 1 | export interface Logger { 2 | error(message: string, obj?: Record): void; 3 | info(message: string, obj?: Record): void; 4 | warn(message: string, obj?: Record): void; 5 | debug(message: string, obj?: Record): void; 6 | } 7 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Services/Commands/SuspendAccountCommand.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const suspendAccountCommandSchema = z.object({ 5 | accountId: z.string().uuid(), 6 | }); 7 | 8 | export class SuspendAccountCommand extends createZodDto(suspendAccountCommandSchema) {} 9 | -------------------------------------------------------------------------------- /packages/zod-dto/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@abitia/tsconfig", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "rootDir": "./src", 6 | "experimentalDecorators": true, 7 | "emitDecoratorMetadata": true, 8 | "declaration": true, 9 | "skipLibCheck": true 10 | }, 11 | "include": [ 12 | "src" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Events/AccountCreatedEvent.ts: -------------------------------------------------------------------------------- 1 | import { Event } from '../../Core/EventBus'; 2 | import { AccountId } from '../Entities/Account'; 3 | 4 | export class AccountCreatedEvent extends Event { 5 | public constructor( 6 | public readonly accountId: AccountId, 7 | ) { 8 | super(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Events/AccountSuspendedEvent.ts: -------------------------------------------------------------------------------- 1 | import { Event } from '../../Core/EventBus'; 2 | import { AccountId } from '../Entities/Account'; 3 | 4 | export class AccountSuspendedEvent extends Event { 5 | public constructor( 6 | public readonly accountId: AccountId, 7 | ) { 8 | super(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/__tests__/utils/createTestToken.ts: -------------------------------------------------------------------------------- 1 | import { createTestTokenFactory } from '../../../Core/Auth/Testing/createTestTokenFactory'; 2 | 3 | import { createTestConfig } from './createTestConfig'; 4 | 5 | const testConfig = createTestConfig(); 6 | 7 | export const createTestToken = createTestTokenFactory(testConfig.jwtSecretKey); 8 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Dto/CreateAccountDto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const createAccountDtoSchema = z.object({ 5 | email: z.string().min(5), 6 | password: z.string().min(6), 7 | }); 8 | 9 | export class CreateAccountDto extends createZodDto(createAccountDtoSchema) {} 10 | -------------------------------------------------------------------------------- /services/monolith/src/Core/EventBus/Event.ts: -------------------------------------------------------------------------------- 1 | export abstract class Event { 2 | public readonly createdAt = new Date(); 3 | 4 | public get name(): string { 5 | return this.constructor.name; 6 | } 7 | 8 | // Hack: Allow child classes to override constructor parameters 9 | public constructor(...args: unknown[]) { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Dto/CreateAuthTokenDto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const createAuthTokenDtoSchema = z.object({ 5 | email: z.string().min(5), 6 | password: z.string().min(6), 7 | }); 8 | 9 | export class CreateAuthTokenDto extends createZodDto(createAuthTokenDtoSchema) {} 10 | -------------------------------------------------------------------------------- /services/monolith/src/Core/EventBus/EventBus.ts: -------------------------------------------------------------------------------- 1 | import { Event } from './Event'; 2 | 3 | export const EVENT_BUS = 'EVENT_BUS'; 4 | 5 | export type EventBusSubscriber = (event: T) => void|Promise; 6 | 7 | export interface EventBus { 8 | publish(event: Event): void; 9 | 10 | subscribe(event: T, subscriber: EventBusSubscriber): void; 11 | } 12 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Outbox/Testing/TestOutbox.ts: -------------------------------------------------------------------------------- 1 | import { Event } from '../../EventBus'; 2 | import { Outbox } from '../Outbox'; 3 | 4 | export class TestOutbox implements Outbox { 5 | public readonly sentEvents: Event[] = []; 6 | 7 | public send(event: Event): Promise { 8 | this.sentEvents.push(event); 9 | 10 | return Promise.resolve(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/Repositories/AuctionRepository.ts: -------------------------------------------------------------------------------- 1 | import { Auction } from '../Entities/Auction'; 2 | 3 | export interface AuctionRepository { 4 | save(newAccount: Auction): Promise; 5 | 6 | findById(id: string): Promise; 7 | 8 | findOpenByAccountId(accountId: string): Promise; 9 | } 10 | 11 | export const AUCTION_REPOSITORY = 'AuctionRepository'; 12 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/Services/Commands/PlaceAuctionBidCommand.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const placeAuctionBidCommandSchema = z.object({ 5 | auctionId: z.string().uuid(), 6 | buyerId: z.string().uuid(), 7 | price: z.number(), 8 | }); 9 | 10 | export class PlaceAuctionBidCommand extends createZodDto(placeAuctionBidCommandSchema) {} 11 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Testing/runMikroOrmMigrations.ts: -------------------------------------------------------------------------------- 1 | import { MikroORM } from '@mikro-orm/core'; 2 | import { INestApplication } from '@nestjs/common'; 3 | 4 | export const runMikroOrmMigrations = async (app: INestApplication): Promise => { 5 | const orm = app.get(MikroORM); 6 | const generator = orm.getSchemaGenerator(); 7 | await generator.dropSchema(); 8 | await generator.createSchema(); 9 | }; 10 | -------------------------------------------------------------------------------- /services/monolith/src/Core/EventBus/NestJs/nestJsInMemoryEventBusProvider.ts: -------------------------------------------------------------------------------- 1 | import { Logger, LOGGER } from '../../Logger'; 2 | import { EVENT_BUS } from '../EventBus'; 3 | import { InMemoryEventBus } from '../InMemoryEventBus'; 4 | 5 | export const nestJsInMemoryEventBusProvider = { 6 | provide: EVENT_BUS, 7 | useFactory: (logger: Logger) => { 8 | return new InMemoryEventBus(logger); 9 | }, 10 | inject: [LOGGER], 11 | }; 12 | -------------------------------------------------------------------------------- /packages/zod-dto/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'moduleFileExtensions': [ 3 | 'ts', 4 | 'tsx', 5 | 'js', 6 | 'json' 7 | ], 8 | 'transform': { 9 | '^.+\\.tsx?$': 'ts-jest' 10 | }, 11 | 'testRegex': '/src/.*\\.(test|spec).(ts|tsx|js)$', 12 | 'collectCoverageFrom' : ['src/**/*.{js,jsx,tsx,ts}', '!**/node_modules/**', '!**/vendor/**'], 13 | 'coverageReporters': ['json', 'lcov'] 14 | }; 15 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/Services/Commands/CreateAuctionCommand.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const createAuctionCommandSchema = z.object({ 5 | item: z.string().min(5), 6 | startingPrice: z.number().int(), 7 | type: z.enum(['buy-it-now', 'auctions']), 8 | sellerId: z.string().uuid(), 9 | }); 10 | 11 | export class CreateAuctionCommand extends createZodDto(createAuctionCommandSchema) {} 12 | -------------------------------------------------------------------------------- /packages/eslint-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@abitia/eslint-config", 3 | "version": "1.1.0", 4 | "description": "ESLint configuration for @abitia", 5 | "author": "Jakub Kisielewski", 6 | "license": "MIT", 7 | "main": "eslint-rules.js", 8 | "scripts": { 9 | "build": "exit 0" 10 | }, 11 | "dependencies": { 12 | "@rushstack/eslint-patch": "1.0.6", 13 | "@typescript-eslint/eslint-plugin": "4.15.0", 14 | "@typescript-eslint/parser": "4.15.0", 15 | "eslint-plugin-import": "2.22.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /services/monolith/src/AuctionContext/Controllers/Dto/CreateAuctionDto.ts: -------------------------------------------------------------------------------- 1 | import { createZodDto } from '@abitia/zod-dto'; 2 | import * as z from 'zod'; 3 | 4 | const createAuctionDtoSchema = z.object({ 5 | item: z.string().min(5), // Todo: This should be a reference to an Item, an item locking system should be designed 6 | startingPrice: z.number().int(), 7 | type: z.enum(['buy-it-now', 'auctions']) 8 | .default('buy-it-now'), 9 | }); 10 | 11 | export class CreateAuctionDto extends createZodDto(createAuctionDtoSchema) {} 12 | -------------------------------------------------------------------------------- /services/monolith/src/AccountContext/Repositories/AccountRepository.ts: -------------------------------------------------------------------------------- 1 | import * as E from '../../Core/Fp/Either'; 2 | import { Account, AccountWithThisEmailAlreadyExistsError } from '../Entities/Account'; 3 | 4 | export interface AccountRepository { 5 | save(newAccount: Account): Promise>; 6 | 7 | findById(id: string): Promise; 8 | 9 | findByEmail(email: string): Promise; 10 | } 11 | 12 | export const ACCOUNT_REPOSITORY = 'AccountRepository'; 13 | -------------------------------------------------------------------------------- /services/monolith/src/Core/Logger/NestJs/nestJsLoggerProvider.ts: -------------------------------------------------------------------------------- 1 | import { PinoLogger } from '../PinoLogger'; 2 | import { pinoFactory } from '../pinoFactory'; 3 | 4 | export const LOGGER = 'LOGGER'; 5 | export const PINO_INSTANCE = 'PINO_INSTANCE'; 6 | 7 | export const nestJsLoggerProvider = [ 8 | { 9 | provide: LOGGER, 10 | useFactory: (pinoInstance) => { 11 | return new PinoLogger(pinoInstance); 12 | }, 13 | inject: [PINO_INSTANCE], 14 | }, 15 | { 16 | provide: PINO_INSTANCE, 17 | useFactory: () => pinoFactory(), 18 | }, 19 | ]; 20 | -------------------------------------------------------------------------------- /common/config/rush/.npmrc: -------------------------------------------------------------------------------- 1 | # Rush uses this file to configure the package registry, regardless of whether the 2 | # package manager is PNPM, NPM, or Yarn. Prior to invoking the package manager, 3 | # Rush will always copy this file to the folder where installation is performed. 4 | # When NPM is the package manager, Rush works around NPM's processing of 5 | # undefined environment variables by deleting any lines that reference undefined 6 | # environment variables. 7 | # 8 | # DO NOT SPECIFY AUTHENTICATION CREDENTIALS IN THIS FILE. It should only be used 9 | # to configure registry sources. 10 | 11 | registry=https://registry.npmjs.org/ 12 | always-auth=false 13 | -------------------------------------------------------------------------------- /.run/Start Monolith.run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |