Skip to content

Commit

Permalink
feat: remove nest-cls packages & start OutboxPattern impl -> see Forg…
Browse files Browse the repository at this point in the history
…otPassword
  • Loading branch information
Gi-jutsu committed Nov 21, 2024
1 parent f85ed69 commit 3540382
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 343 deletions.
1 change: 0 additions & 1 deletion drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema: [
"./src/identity-and-access/infrastructure/database/drizzle/schema.ts",
"./src/shared-kernel/infrastructure/database/drizzle/schema.ts",
],
dialect: "postgresql",
dbCredentials: {
Expand Down
7 changes: 0 additions & 7 deletions drizzle/0002_messy_malcolm_colcord.sql

This file was deleted.

206 changes: 0 additions & 206 deletions drizzle/meta/0002_snapshot.json

This file was deleted.

9 changes: 1 addition & 8 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
"when": 1728664010372,
"tag": "0001_illegal_sunset_bain",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1731767198787,
"tag": "0002_messy_malcolm_colcord",
"breakpoints": true
}
]
}
}
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
"vitest": "^2.1.4"
},
"dependencies": {
"@nestjs-cls/transactional": "^2.4.2",
"@nestjs-cls/transactional-adapter-drizzle-orm": "^1.1.1",
"@nestjs/common": "^10.4.7",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.4.7",
Expand Down
38 changes: 0 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions src/core/primitives/domain-event.base.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import { randomUUID } from "node:crypto";

interface CreateDomainEventProps<Payload = Record<string, unknown>> {
aggregateId: string;
payload: Payload;
}

export abstract class DomainEvent<Payload = Record<string, unknown>> {
readonly id: string;
readonly metadata: {
// @TODO: Implement 'correlationId' in the future
// correlationId: string;
emittedByAggregateId: string;
};
readonly payload: Payload;
readonly type: string;

constructor(properties: CreateDomainEventProps<Payload>) {
this.id = randomUUID();
this.metadata = {
emittedByAggregateId: properties.aggregateId,
};
this.payload = properties.payload;
this.type = this.constructor.name;
}
}
7 changes: 6 additions & 1 deletion src/identity-and-access/identity-and-access.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { JwtServiceToken } from "@identity-and-access/infrastructure/services/jwt.service.js";
import { Module } from "@nestjs/common";
import { OutboxMessageRepositoryToken } from "@shared-kernel/domain/outbox-message/repository.js";
import { AccountRepositoryToken } from "./domain/account/repository.js";
import { PasswordResetRequestRepositoryToken } from "./domain/password-reset-request/repository.js";
import { DrizzleAccountRepository } from "./infrastructure/repositories/drizzle-account.repository.js";
Expand Down Expand Up @@ -40,7 +41,11 @@ import { SignUpWithCredentialsUseCase } from "./use-cases/sign-up-with-credentia
useFactory: (
...args: ConstructorParameters<typeof ForgotPasswordUseCase>
) => new ForgotPasswordUseCase(...args),
inject: [AccountRepositoryToken, PasswordResetRequestRepositoryToken],
inject: [
AccountRepositoryToken,
PasswordResetRequestRepositoryToken,
OutboxMessageRepositoryToken,
],
},
{
provide: SignInWithCredentialsUseCase,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { TransactionalAdapterDrizzleOrm } from "@nestjs-cls/transactional-adapter-drizzle-orm";
import { sql } from "drizzle-orm";
import { NodePgDatabase } from "drizzle-orm/node-postgres";
import {
Expand Down Expand Up @@ -56,6 +55,3 @@ export const passwordResetRequestSchema = pgTable(
export type IdentityAndAccessDatabase = NodePgDatabase<{
accounts: typeof accountSchema;
}>;

export type IdentityAndAccessDatabaseTransactionAdapter =
TransactionalAdapterDrizzleOrm<IdentityAndAccessDatabase>;
Loading

0 comments on commit 3540382

Please sign in to comment.