Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
758 changes: 710 additions & 48 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@
"prisma:reset": "prisma migrate reset && prisma db seed"
},
"dependencies": {
"@nestjs/class-transformer": "^0.4.0",
"@nestjs/class-validator": "^0.13.4",
"@nestjs/common": "^11.1.19",
"@nestjs/config": "^4.0.4",
"@nestjs/core": "^11.1.19",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.3.0",
"@nestjs/typeorm": "^11.0.1",
"@prisma/adapter-pg": "^7.7.0",
"@prisma/client": "^7.7.0",
"class-validator": "^0.15.1",
"pg": "^8.20.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.1"
"sanitize-html": "^2.17.3",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.28"
Comment thread
MCSwainConnor marked this conversation as resolved.
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,16 @@ CREATE TABLE "Product" (
CONSTRAINT "Product_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Order" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" TEXT NOT NULL,
"size" TEXT,
"costumer" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "Order_pkey" PRIMARY KEY ("id")
);
Comment on lines +22 to +31
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Spelling: costumercustomer.

The new Order.costumer column (line 27) is a typo that propagates into the Prisma schema, DTOs, mapper, and service. Renaming later requires a DB migration plus code changes across every layer; fixing it now while the column is still brand-new is essentially free.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@prisma/migrations/20260422114150/migration.sql` around lines 22 - 31, The
"Order" table column is misspelled as "costumer" — update the migration SQL to
rename the column to "customer" in the CREATE TABLE statement and then propagate
that rename through the codebase by updating the Prisma schema model Order
field, all DTOs, mapper functions, and any service methods that reference
"costumer"; search for the exact token "costumer" and replace with "customer",
regenerate the Prisma client (prisma generate) and run tests to ensure no
remaining references exist.


-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
10 changes: 9 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ model Product {
size String?
description String?
createdAt DateTime @default(now()) @db.Timestamptz(6)
}
}

model Order {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eine Order besteht immer aus mehreren Items eigentlich.

Für Order gibt es mehrere Anforderungen:

  • sie muss den konkreten Item - stand zum zeitpunkt des kaufs wiederspiegeln. (kopie der tatsächlichen items)
  • Pro "Order" kann man mehrere Items haben.
  • Pro "Order" gibt es vlt noch einen bestellstatus etc.

--> damit du jetzt noch datenbankdesign lernst:

Erstelle ein ER Diagram das die datenbank beschreibt entsprechend dem Standard.

  • Inklusive der beziehungen
  • Inklusive der felder mit datentyp
  • Inklusive der FK PKs

Wir haben folgende Tabellen

  • User

  • Product

  • Order

  • OrderItem

  • Eine Order soll immer mehrere OrderItems gruppieren. (eine bestellung)

  • Eine Order hat einen OrderStatus als enum - Created, Ordered, Canceled, Done

  • Jedes OrderItem kopiert im prinzip die daten eines Products zum Zeitpunkt der Bestellung

  • Jedes OrderItem hat zusätzlich eine referenz zu dem original Produkt

id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
size String?
costumer String
createdAt DateTime @default(now()) @db.Timestamptz(6)
}
Comment on lines +26 to +32
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Data model: customer should likely be a relation, not a free-text string.

Storing costumer (sic) as String denormalizes customer identity and precludes joining to User. Unless this is explicitly a guest-checkout name field, model it as customerId String @db.Uuid`` + customer User @relation`(fields: [customerId], references: [id])`. Also consider a relation to `Product` (what was actually ordered?) — the current `name` + `size` pair on `Order` duplicates product data and will drift.

Note: the costumer misspelling flagged on the DTO applies here too — fix it in the schema and regenerate the migration before this lands in main, since renaming a column post-release is disruptive.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@prisma/schema.prisma` around lines 26 - 32, The Order model currently stores
customer as the misspelled free-text field costumer and duplicates product info
in name/size; change Order by renaming costumer to customerId (type String
`@db.Uuid`) and add a relation field customer User `@relation`(fields: [customerId],
references: [id]) so Orders reference the User model (update any DTOs that used
costumer), and replace the product name/size pair with a proper relation such as
productId String `@db.Uuid` and product Product `@relation`(fields: [productId],
references: [id]) (or explicitly mark name/size as guest fields if intended);
after editing the Order model and fixing the misspelling, regenerate the
migration so the schema change is applied cleanly before merging.

3 changes: 2 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PrismaModule } from './modules/prisma/prisma.module';
import { ProductModule } from './modules/products/product.module';
import { OrdersModule } from './modules/orders/order.module';

@Module({
imports: [ConfigModule.forRoot(), PrismaModule, ProductModule],
imports: [ConfigModule.forRoot(), PrismaModule, ProductModule, OrdersModule],
controllers: [AppController],
providers: [AppService],
})
Expand Down
17 changes: 17 additions & 0 deletions src/modules/orders/dto/create-order.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';

export class CreateOrderDto {
@IsString()
@IsNotEmpty()
@MaxLength(128)
name!: string;

@IsString()
@IsOptional()
size?: string;

@IsString()
@IsNotEmpty()
@MaxLength(128)
costumer!: string;
Comment on lines +13 to +16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Typo: costumer should be customer.

The field name costumer (a person wearing costumes) is misspelled throughout the stack — this DTO, prisma/schema.prisma (the Order.costumer column), and OrderService.create. Fixing this later requires a DB migration and a breaking API change, so correct it now before the endpoint ships.

🛠️ Proposed fix
   `@IsString`()
   `@IsNotEmpty`()
   `@MaxLength`(128)
-  costumer!: string;
+  customer!: string;

Apply the same rename in prisma/schema.prisma (model Order) and regenerate the migration.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@IsString()
@IsNotEmpty()
@MaxLength(128)
costumer!: string;
`@IsString`()
`@IsNotEmpty`()
`@MaxLength`(128)
customer!: string;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/orders/dto/create-order.dto.ts` around lines 13 - 16, The field
name costumer is misspelled; rename it to customer across the codebase: update
the DTO property in create-order.dto.ts (costumer -> customer), update the
Prisma model Order (Order.costumer -> Order.customer) and run prisma migrate/dev
(or create a migration) then regenerate the Prisma client, and update all
references and method signatures/usages such as OrderService.create and any
DTO/validation, controller, or repository code that refer to costumer to use
customer instead.

}
19 changes: 19 additions & 0 deletions src/modules/orders/dto/update-order.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { PartialType } from '@nestjs/swagger';
import { CreateOrderDto } from './create-order.dto';
import { IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';

export class UpdateOrderDto extends PartialType(CreateOrderDto) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wenn du PartialType nutzt (an sich ok - wenn du wirklich alle felder von create auch updaten willst)
dann bringt es nichts alle felder nochmal aufzulisten. dann kannst du dir das partial sparen.

@IsString()
@IsNotEmpty()
@MaxLength(128)
name!: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Außerdem: in Update benutzt du ja "PATCH" und mit patch sollte man auch nur einen Teil der fleder updaten können.

Wenn du sie hier aber wieder required machst dann muss man ja immer alle mitgeben.

Ich hab zwar des PartialType noch nie verwendet, aber ich glaube es macht das schon korrekt.

dementsprechend würde

export class UpdateOrderDto extends PartialType(CreateOrderDto) { }

komplett reichen

(siehe rabbit comment)

Es gibt noch weiter Nestjs tools um zu vermeiden dtos doppelt zu schreiben, die kann man nutzten - aber immer mit bedacht. Zu viel krossreferenzierung macht den code auch nicht lesbarer :-)
(https://docs.nestjs.com/openapi/mapped-types)


@IsString()
@IsOptional()
size?: string;

@IsString()
@IsNotEmpty()
@MaxLength(128)
costumer!: string;
}
Comment on lines +5 to +19
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Re-declaring fields nullifies PartialType and breaks PATCH semantics.

PartialType(CreateOrderDto) already makes every field optional and carries over validation decorators. By re-declaring name, size, costumer here with @IsNotEmpty() and definite-assignment (!), you overwrite the partial metadata and force clients to send name and costumer on every PATCH /orders/:id — which defeats the purpose of a partial update DTO.

🛠 Proposed fix
 import { PartialType } from '@nestjs/swagger';
 import { CreateOrderDto } from './create-order.dto';
-import { IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
 
-export class UpdateOrderDto extends PartialType(CreateOrderDto) {
-  `@IsString`()
-  `@IsNotEmpty`()
-  `@MaxLength`(128)
-  name!: string;
-
-  `@IsString`()
-  `@IsOptional`()
-  size?: string;
-
-  `@IsString`()
-  `@IsNotEmpty`()
-  `@MaxLength`(128)
-  costumer!: string;
-}
+export class UpdateOrderDto extends PartialType(CreateOrderDto) {}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/orders/dto/update-order.dto.ts` around lines 5 - 19, The
UpdateOrderDto class is re-declaring name, size, and costumer which overrides
PartialType(CreateOrderDto) and forces required fields; remove the explicit
property declarations from UpdateOrderDto so it simply extends
PartialType(CreateOrderDto) (or if you need extra rules, declare the same
properties as optional (e.g., name?: string) and avoid `@IsNotEmpty`() /
definite-assignment `!`, or use conditional validators like `@ValidateIf` to keep
PATCH semantics). Ensure UpdateOrderDto relies on PartialType(CreateOrderDto)
for optionality and validation metadata instead of redeclaring name, size,
costumer.

10 changes: 10 additions & 0 deletions src/modules/orders/mappings/order-dto.mappers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Order } from '../../../generated/prisma/client';
import { CreateOrderDto } from '../dto/create-order.dto';

export function mapOrderDTO(order: Order): CreateOrderDto {
return {
name: order.name,
size: order.size ?? undefined,
costumer: order.costumer,
};
}
Comment on lines +4 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Mapper drops id and createdAt — likely wrong target type.

Mapping a persisted Order into CreateOrderDto loses id/createdAt, so callers receiving this result cannot identify or order records. A mapper from entity → response DTO should produce a response type that includes id and createdAt (or re-use Order directly). If the intent is input-shape reuse, the naming mapOrderDTO is misleading.

Please either introduce an OrderDto/OrderResponseDto that includes id and createdAt, or remove this mapper if it's unused.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/orders/mappings/order-dto.mappers.ts` around lines 4 - 10, The
mapOrderDTO function currently maps an Order to CreateOrderDto and drops id and
createdAt; update this by either (A) creating a new response type (e.g.,
OrderDto or OrderResponseDto) that includes id and createdAt and change
mapOrderDTO's return type to that, ensuring mapOrderDTO(order: Order) returns {
id: order.id, name: order.name, size: order.size ?? undefined, costumer:
order.costumer, createdAt: order.createdAt }, or (B) if the mapper was intended
only for input reuse, delete mapOrderDTO and rename any usages to make intent
clear (or rename function to mapOrderInputDto) so callers use the full Order
type for responses; adjust all references to mapOrderDTO and CreateOrderDto
accordingly.

20 changes: 20 additions & 0 deletions src/modules/orders/order.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OrdersController } from './order.controller';
import { OrderService } from './order.service';

describe('OrdersController', () => {
let controller: OrdersController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [OrdersController],
providers: [OrderService],
}).compile();
Comment on lines +8 to +12
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the DI mismatch without running tests.
rg -n -C3 --type=ts 'class OrdersService|constructor\(private readonly prisma: PrismaService\)|controllers:\s*\[OrdersController\]|providers:\s*\[OrdersService\]'

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 2206


🏁 Script executed:

# Check OrdersController to see what OrdersService methods are called
rg -n -A 10 'class OrdersController|@' src/modules/orders/orders.controller.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 1079


Mock OrdersService so this controller spec can compile.

OrdersService requires PrismaService, but this test registers the real service without providing that dependency. Use a service mock instead of pulling in the database layer.

🧪 Proposed fix
     const module: TestingModule = await Test.createTestingModule({
       controllers: [OrdersController],
-      providers: [OrdersService],
+      providers: [
+        {
+          provide: OrdersService,
+          useValue: {
+            create: jest.fn(),
+            findAll: jest.fn(),
+            findOne: jest.fn(),
+            update: jest.fn(),
+            remove: jest.fn(),
+          },
+        },
+      ],
     }).compile();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/orders/orders.controller.spec.ts` around lines 8 - 12, The test
registers the real OrdersService which depends on PrismaService; replace it with
a mock so the controller test compiles. In the
beforeEach/Test.createTestingModule setup, provide a mocked OrdersService by
using a provider object (provide: OrdersService, useValue: mockOrdersService)
instead of the real class; create a simple mockOrdersService object that
implements the methods the OrdersController calls (e.g., findAll, findOne,
create, etc.) returning suitable stubs or promises, then compile the
TestingModule and inject OrdersController as before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MCSwainConnor Mocking und test schreiben müssen wir uns denke ich getrennt ma unterhalten

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!


controller = module.get<OrdersController>(OrdersController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
25 changes: 25 additions & 0 deletions src/modules/orders/order.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Body, Controller, Delete, Param, Patch, Post } from '@nestjs/common';
import { Order } from '../../generated/prisma/client';
import { CreateOrderDto } from './dto/create-order.dto';
import { UpdateOrderDto } from './dto/update-order.dto';
import { OrderService } from './order.service';

@Controller('orders')
export class OrdersController {
constructor(private readonly orderService: OrderService) {}

@Post()
create(@Body() createOrderDto: CreateOrderDto): Promise<Order> {
return this.orderService.create(createOrderDto);
}

@Patch(':id')
update(@Param('id') id: string, @Body() updateOrderDto: UpdateOrderDto): Promise<Order> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

für die Incoming daten kannst du auch DTOs verwenden, was cooler ist

z.b.

Suggested change
update(@Param('id') id: string, @Body() updateOrderDto: UpdateOrderDto): Promise<Order> {
update(@Param() param: OrderIdParamDTO, @Body() updateOrderDto: UpdateOrderDto): Promise<Order> {

Hier gibt es jetzt viele möglichkeiten das zu designen. Wenn du bestimmte ids öfter verwendest kannst du ein gemeinsames Id dto machen.

@Patch(':orderId')
export class OrderIdParamDTO {
  @ApiProperty({ example: '908096da-ade0-415b-aa40-48f53ff34b9c' }) 
  @IsUUID()
  orderId!: string;
}

Vorteil im vergleich zu deinem:

  • du kannst ein example mitgeben mit einer ID aus den seed daten.
    Dann wirds im swagger gleich vorausgefüllt. Finde es auch immer praktisch wenn jeder request examples definiert hat so dass man in der swagger ui zum ausprobieren einfach nur auf senden klicken muss.
  • validierung auf IsUUID
  • naming: ich finde es immer besser wenn du im code die ids nach dem benenst was für ids sie sind. (also wenn die id wo ein parameter oder so ist.)

return this.orderService.update(id, updateOrderDto);
}

@Delete(':id')
remove(@Param('id') id: string): Promise<Order> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dann kannst dus hier genauso machen

return this.orderService.remove(id);
}
Comment thread
ac-tiffi marked this conversation as resolved.
}
Comment thread
ac-tiffi marked this conversation as resolved.
11 changes: 11 additions & 0 deletions src/modules/orders/order.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { OrderService } from './order.service';
import { OrdersController } from './order.controller';
import { PrismaModule } from '../../prisma/prisma.module';

@Module({
imports: [PrismaModule],
controllers: [OrdersController],
providers: [OrderService],
})
export class OrdersModule {}
18 changes: 18 additions & 0 deletions src/modules/orders/order.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OrderService } from './order.service';

describe('OrderService', () => {
let service: OrderService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [OrderService],
}).compile();
Comment on lines +8 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify OrdersService's required dependency and the current spec provider list.
rg -n -C3 --type=ts 'class OrdersService|constructor\(private readonly prisma: PrismaService\)|describe\(.\x27OrdersService.\x27|providers:\s*\[OrdersService\]'

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 2119


🏁 Script executed:

#!/bin/bash
# Check the import path for PrismaService in orders.service.ts
head -10 src/modules/orders/orders.service.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 439


Provide a PrismaService mock for this service spec.

OrdersService cannot be instantiated without PrismaService in the testing module. The current provider list only includes OrdersService, but its constructor requires PrismaService as a dependency, causing test compilation to fail.

🧪 Proposed fix
 import { Test, TestingModule } from '@nestjs/testing';
 import { OrdersService } from './orders.service';
+import { PrismaService } from '../../prisma/prisma.service';
 
 describe('OrdersService', () => {
   let service: OrdersService;
 
   beforeEach(async () => {
     const module: TestingModule = await Test.createTestingModule({
-      providers: [OrdersService],
+      providers: [
+        OrdersService,
+        {
+          provide: PrismaService,
+          useValue: {
+            create: jest.fn(),
+            findAll: jest.fn(),
+            findOne: jest.fn(),
+            update: jest.fn(),
+            remove: jest.fn(),
+          },
+        },
+      ],
     }).compile();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/orders/orders.service.spec.ts` around lines 8 - 10, The test
module fails because OrdersService depends on PrismaService but the test
providers only include OrdersService; update the Test.createTestingModule call
to provide a mock PrismaService (e.g., add a provider object with provide:
PrismaService and useValue: a minimal stub/mock implementing the Prisma methods
used by OrdersService or jest.fn() spies) so the DI can resolve the dependency;
ensure the mock is added to the providers array passed into
Test.createTestingModule before calling .compile() and that its methods return
the shapes OrdersService expects.


service = module.get<OrderService>(OrderService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
34 changes: 34 additions & 0 deletions src/modules/orders/order.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Injectable } from '@nestjs/common';
import { Order } from '../../generated/prisma/client';
import { PrismaService } from '../../prisma/prisma.service';
import { CreateOrderDto } from './dto/create-order.dto';
import { UpdateOrderDto } from './dto/update-order.dto';

@Injectable()
export class OrderService {
constructor(private readonly prisma: PrismaService) {}

async create(order: CreateOrderDto): Promise<Order> {
return this.prisma.order.create({
data: {
...order,
createdAt: new Date(),
},
});
}
Comment on lines +11 to +18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Drop the manual createdAt assignment.

The Prisma schema defines createdAt DateTime @default(now()) @db.Timestamptz(6), so Postgres will populate it. Setting createdAt: new Date() here overrides that with the app server's wall clock (timezone/skew sensitive) and adds noise to the insert. Spread the DTO alone.

🛠️ Proposed fix
   async create(order: CreateOrderDto): Promise<Order> {
     return this.prisma.order.create({
-      data: {
-        ...order,
-        createdAt: new Date(),
-      },
+      data: { ...order },
     });
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async create(order: CreateOrderDto): Promise<Order> {
return this.prisma.order.create({
data: {
...order,
createdAt: new Date(),
},
});
}
async create(order: CreateOrderDto): Promise<Order> {
return this.prisma.order.create({
data: { ...order },
});
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/modules/orders/order.service.ts` around lines 11 - 18, In create(order:
CreateOrderDto) within OrderService (async create), remove the manual createdAt:
new Date() from the data passed to prisma.order.create so Prisma/Postgres can
use the schema default; simply spread the DTO (data: { ...order }) and ensure
CreateOrderDto does not force a createdAt field before calling prisma to avoid
overriding the DB default.


async findAll(): Promise<Order[]> {
return this.prisma.order.findMany();
}

async update(id: string, data: UpdateOrderDto): Promise<Order> {
return this.prisma.order.update({
where: { id },
data,
});
}

async remove(id: string): Promise<Order> {
return this.prisma.order.delete({ where: { id } });
}
}
16 changes: 16 additions & 0 deletions src/prisma/dto/create-prisma.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IsNotEmpty, IsOptional, IsString, MaxLength } from '@nestjs/class-validator';

export class CreatePrismaDto {
@MaxLength(128)
@IsString()
@IsNotEmpty()
name: string;

@IsString()
@IsOptional()
size?: string;

@IsString()
@IsOptional()
description?: string;
}
Comment on lines +1 to +16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
fd -t f "main.ts" src | xargs -I{} sh -c 'echo "=== {} ==="; cat "{}"'

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 798


🏁 Script executed:

cat -n package.json

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 3229


🏁 Script executed:

fd -t f "schema.prisma" . | head -1 | xargs cat

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 649


🏁 Script executed:

fd -t f "*prisma.service.ts" src | xargs cat

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 372


🏁 Script executed:

fd -t f "*.controller.ts" src | xargs grep -l "prisma\|product" -i

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 371


🏁 Script executed:

fd -g "*service.ts" src | head -20

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 236


🏁 Script executed:

fd -g "*controller.ts" src | head -20

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 211


🏁 Script executed:

rg "productsDelegate|PrismaService" src -A 2 -B 2 | head -50

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 3455


🏁 Script executed:

rg "CreatePrismaDto|CreateProductDto" src

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 771


🏁 Script executed:

cat -n src/prisma/prisma.service.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 2481


🏁 Script executed:

cat -n src/prisma/prisma.controller.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 1234


🏁 Script executed:

rg "@nestjs/class-validator" . --type-list | head -5

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 464


🏁 Script executed:

rg "deprecated\|class-validator" . -i | head -20

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 57


🏁 Script executed:

rg "class-validator" package.json -A 2 -B 2

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 245


🏁 Script executed:

rg "deprecated" . --type json

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 361


🏁 Script executed:

head -n 50 package.json | tail -n 30

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 1002


ValidationPipe must be registered in main.ts for decorators to take effect; naming contradicts NestJS conventions.

  1. Critical: No ValidationPipe is configured in main.ts. All validation decorators (including @IsNotEmpty, @MaxLength, etc.) are currently silently ignored at runtime. Add: app.useGlobalPipes(new ValidationPipe({ whitelist: true, forbidNonWhitelowed: true })) before app.listen().

  2. Naming smell: The DTO/controller/service are named after the ORM (CreatePrismaDto, PrismaController, PrismaService with route @Controller('prisma')) instead of the entity (Product). This contradicts NestJS conventions where PrismaService should be a thin shared client wrapper in src/modules/prisma/. The entity-specific service should be in src/modules/products/ with route @Controller('products'). Note: correct ProductService and ProductsController already exist in the codebase; consolidate to avoid duplication.

  3. Import source: Switch from @nestjs/class-validator to the standard class-validator package.

  4. Input bounds: Add @MaxLength constraints to optional fields to prevent unbounded input:

    • size: suggest @MaxLength(64)
    • description: suggest @MaxLength(2048)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/dto/create-prisma.dto.ts` around lines 1 - 16, Register the global
ValidationPipe in main.ts (call app.useGlobalPipes(new ValidationPipe({
whitelist: true, forbidNonWhitelowed: true })) before app.listen()) so the
decorators on CreatePrismaDto are enforced; rename and consolidate ORM-named
artifacts to domain names (rename CreatePrismaDto → CreateProductDto, move
PrismaController/PrismaService responsibilities so PrismaService remains the
thin DB client and use ProductService/ProductsController for product routes) to
avoid duplication with existing ProductService/ProductsController; change the
import from `@nestjs/class-validator` to class-validator in the DTO file and add
`@MaxLength`(64) to size and `@MaxLength`(2048) to description on the DTO class
fields to bound input.

4 changes: 4 additions & 0 deletions src/prisma/dto/update-prisma.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreatePrismaDto } from './create-prisma.dto';

export class UpdatePrismaDto extends PartialType(CreatePrismaDto) {}
1 change: 1 addition & 0 deletions src/prisma/entities/prisma.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Prisma {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Empty placeholder entity — remove or populate.

Prisma is an empty class with no fields, no decorators, and no references elsewhere in the PR. It also shadows the name of the widely used Prisma namespace exported by @prisma/client, which will cause confusing import collisions as the codebase grows. Either delete this file or replace it with a meaningful domain entity (and rename — e.g. Product).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/entities/prisma.entity.ts` at line 1, The file contains an empty
placeholder class named Prisma which both provides no functionality and
conflicts with the `@prisma/client` Prisma namespace; either remove this class
entirely or replace it with a real domain entity and a non-conflicting name
(e.g., rename class Prisma to Product and add appropriate fields/decorators) and
update any imports accordingly so the shadowed Prisma symbol is eliminated.

20 changes: 20 additions & 0 deletions src/prisma/prisma.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { PrismaController } from './prisma.controller';
import { PrismaService } from './prisma.service';

describe('PrismaController', () => {
let controller: PrismaController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [PrismaController],
providers: [PrismaService],
}).compile();

controller = module.get<PrismaController>(PrismaController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
Comment on lines +1 to +20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect PrismaService to see whether it connects on init.
fd -t f "prisma.service.ts" | xargs -I{} sh -c 'echo "=== {} ==="; cat "{}"'

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 2658


Mock PrismaService to avoid real database connection in tests.

PrismaService extends PrismaClient and calls $connect() during module initialization. Providing it directly in providers will attempt a real database connection, failing the test. Use a mock instead:

Suggested fix
-    const module: TestingModule = await Test.createTestingModule({
-      controllers: [PrismaController],
-      providers: [PrismaService],
-    }).compile();
+    const module: TestingModule = await Test.createTestingModule({
+      controllers: [PrismaController],
+      providers: [
+        {
+          provide: PrismaService,
+          useValue: {
+            create: jest.fn(),
+            findAll: jest.fn(),
+            findOne: jest.fn(),
+            update: jest.fn(),
+            remove: jest.fn(),
+          },
+        },
+      ],
+    }).compile();

Additionally, the single toBeDefined assertion provides no real coverage. Add tests for each CRUD handler's delegation to the service.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { Test, TestingModule } from '@nestjs/testing';
import { PrismaController } from './prisma.controller';
import { PrismaService } from './prisma.service';
describe('PrismaController', () => {
let controller: PrismaController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [PrismaController],
providers: [PrismaService],
}).compile();
controller = module.get<PrismaController>(PrismaController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
import { Test, TestingModule } from '@nestjs/testing';
import { PrismaController } from './prisma.controller';
import { PrismaService } from './prisma.service';
describe('PrismaController', () => {
let controller: PrismaController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [PrismaController],
providers: [
{
provide: PrismaService,
useValue: {
create: jest.fn(),
findAll: jest.fn(),
findOne: jest.fn(),
update: jest.fn(),
remove: jest.fn(),
},
},
],
}).compile();
controller = module.get<PrismaController>(PrismaController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/prisma.controller.spec.ts` around lines 1 - 20, Replace the real
PrismaService provider in the PrismaController test with a mock that stubs out
PrismaService methods (and prevents PrismaClient $connect from being called):
instead of listing PrismaService in providers, provide a mocked value for the
token PrismaService that implements the service methods used by PrismaController
(e.g., create, findAll, findOne, update, remove) and any $connect/$disconnect
no-op, so the test never opens a real DB connection; then add unit tests that
call PrismaController.create / findAll / findOne / update / remove (or the
actual CRUD handler names on PrismaController) and assert they delegate to the
mocked PrismaService methods (using spies/expect calls and returned mock values)
rather than only checking controller toBeDefined.

36 changes: 36 additions & 0 deletions src/prisma/prisma.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { ApiExcludeController } from '@nestjs/swagger';
import { PrismaService } from './prisma.service';
import { CreatePrismaDto } from './dto/create-prisma.dto';
import { UpdatePrismaDto } from './dto/update-prisma.dto';

@ApiExcludeController()
@Controller('prisma')
export class PrismaController {
constructor(private readonly prismaService: PrismaService) {}

@Post()
create(@Body() createPrismaDto: CreatePrismaDto) {
return this.prismaService.create(createPrismaDto);
}

@Get()
findAll() {
return this.prismaService.findAll();
}

@Get(':id')
findOne(@Param('id') id: string) {
return this.prismaService.findOne(id);
}

@Patch(':id')
update(@Param('id') id: string, @Body() updatePrismaDto: UpdatePrismaDto) {
return this.prismaService.update(id, updatePrismaDto);
}

@Delete(':id')
remove(@Param('id') id: string) {
return this.prismaService.remove(id);
Comment on lines +22 to +34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify raw id params and UUID-backed schema fields.
rg -n -C2 --type=ts "@Param\\('id'\\) id: string|ParseUUIDPipe"
rg -n -C2 '@db\\.Uuid|@default\\(dbgenerated\\("gen_random_uuid\\(\\)"\\)\\)'

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 1958


🏁 Script executed:

# Find and examine the Prisma schema file
find . -name "*.prisma" -type f

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 97


🏁 Script executed:

# Check the current imports in prisma.controller.ts
sed -n '1,10p' src/prisma/prisma.controller.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 456


🏁 Script executed:

# Search for UUID field definitions in schema
rg -n "id.*@db\.Uuid|UUID" --type prisma

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 105


🏁 Script executed:

# Check all controllers for similar patterns
rg -l "findOne.*@Param\('id'\)" --type ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 146


🏁 Script executed:

# Read the Prisma schema to check ID field types
cat prisma/schema.prisma

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 649


🏁 Script executed:

# Check orders.controller.ts imports
sed -n '1,10p' src/modules/orders/orders.controller.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 452


Add UUID validation to route parameters.

The Prisma schema defines UUID IDs (@db.Uuid), but route handlers accept any string without validation. This affects both src/prisma/prisma.controller.ts and src/modules/orders/orders.controller.ts. Add ParseUUIDPipe to return 400 for malformed IDs instead of leaking Prisma/database errors.

Proposed fix (src/prisma/prisma.controller.ts)
-import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
+import { Controller, Get, Post, Body, Patch, Param, Delete, ParseUUIDPipe } from '@nestjs/common';
 
   `@Get`(':id')
-  findOne(`@Param`('id') id: string) {
+  findOne(`@Param`('id', ParseUUIDPipe) id: string) {
     return this.prismaService.findOne(id);
   }
 
   `@Patch`(':id')
-  update(`@Param`('id') id: string, `@Body`() updatePrismaDto: UpdatePrismaDto) {
+  update(`@Param`('id', ParseUUIDPipe) id: string, `@Body`() updatePrismaDto: UpdatePrismaDto) {
     return this.prismaService.update(id, updatePrismaDto);
   }
 
   `@Delete`(':id')
-  remove(`@Param`('id') id: string) {
+  remove(`@Param`('id', ParseUUIDPipe) id: string) {
     return this.prismaService.remove(id);
   }

Apply the same changes to src/modules/orders/orders.controller.ts.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Get(':id')
findOne(@Param('id') id: string) {
return this.prismaService.findOne(id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() updatePrismaDto: UpdatePrismaDto) {
return this.prismaService.update(id, updatePrismaDto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.prismaService.remove(id);
import { Controller, Get, Post, Body, Patch, Param, Delete, ParseUUIDPipe } from '@nestjs/common';
`@Get`(':id')
findOne(`@Param`('id', ParseUUIDPipe) id: string) {
return this.prismaService.findOne(id);
}
`@Patch`(':id')
update(`@Param`('id', ParseUUIDPipe) id: string, `@Body`() updatePrismaDto: UpdatePrismaDto) {
return this.prismaService.update(id, updatePrismaDto);
}
`@Delete`(':id')
remove(`@Param`('id', ParseUUIDPipe) id: string) {
return this.prismaService.remove(id);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/prisma.controller.ts` around lines 20 - 32, Add UUID validation to
the route params by importing ParseUUIDPipe from `@nestjs/common` and applying it
to the id route parameters in the PrismaController methods findOne, update, and
remove (i.e., change `@Param`('id') id: string to `@Param`('id', new
ParseUUIDPipe()) id: string) so malformed IDs return 400 instead of reaching
Prisma; make the identical change in the OrdersController methods that accept an
id param (import ParseUUIDPipe there as well and apply new ParseUUIDPipe() to
the id `@Param`).

}
Comment on lines +8 to +35
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify where the Prisma controller is registered and imported.
rg -n -C3 --type=ts "@Controller\\('prisma'\\)|controllers:\\s*\\[PrismaController\\]|imports:\\s*\\[PrismaModule\\]"

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 2284


Remove PrismaController from the module's controllers array.

The PrismaModule currently registers PrismaController, exposing raw CRUD endpoints under /prisma that bypass domain semantics. This creates a public infrastructure layer alongside domain APIs. Keep PrismaModule provider-only by exporting only PrismaService, allowing domain-specific controllers (e.g., ProductsController, OrdersController) to handle HTTP routing with explicit business logic and protections.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/prisma.controller.ts` around lines 6 - 33, Remove PrismaController
from the PrismaModule controllers array and ensure PrismaModule only registers
and exports the PrismaService provider; locate the PrismaModule class (symbol
PrismaModule) and remove PrismaController from its controllers metadata, keeping
PrismaService in the providers and exports lists so domain modules can inject
PrismaService while HTTP routing remains with domain controllers (e.g.,
ProductsController, OrdersController).

}
Comment on lines +1 to +36
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP --type=ts -C2 '\bPrismaController\b'
rg -nP --type=ts -C3 'controllers\s*:\s*\[' src/prisma src/app.module.ts

Repository: Tiffinger-Thiel-GmbH/Merch-Shop

Length of output: 3178


Misleading naming and unauthenticated CRUD surface.

The PrismaController concern has been clarified:

  • Correction: The controller IS registered in PrismaModule.controllers (line 6 of src/prisma/prisma.module.ts), so it is not dead code.

However, a design concern remains:

  • Per PrismaService, every method delegates to productsDelegate(), meaning /prisma provides an unauthenticated CRUD interface over Products with misleading naming. The @ApiExcludeController() decorator hides it from Swagger documentation but does not prevent runtime access.

If /prisma is intended as an internal/temporary endpoint, consider adding an admin guard (@UseGuards(AdminGuard)) or moving the logic to ProductsController to avoid confusion and unintended exposure.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/prisma.controller.ts` around lines 1 - 36, PrismaController is
exposing an unauthenticated CRUD surface over Products (via prismaService ->
productsDelegate) with a misleading name; either secure it or remove/move it:
add an authentication/authorization guard (e.g., annotate the PrismaController
class with `@UseGuards`(AdminGuard) and import/provide AdminGuard) so only admins
can access its create/findAll/findOne/update/remove methods, or move the
create/findAll/findOne/update/remove delegations into the existing
ProductsController and remove PrismaController from PrismaModule.controllers to
avoid duplicate/hidden endpoints; update module registrations and imports
accordingly.

10 changes: 10 additions & 0 deletions src/prisma/prisma.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
import { PrismaController } from './prisma.controller';

@Module({
controllers: [PrismaController],
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}
Comment on lines +1 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Mixing infrastructure and feature concerns in one module.

PrismaModule simultaneously (a) exports PrismaService as shared infrastructure for other modules (OrdersModule, ProductModule both import it) and (b) registers a PrismaController that exposes product CRUD endpoints. These should be split:

  • PrismaModule → only providers: [PrismaService] + exports: [PrismaService] (infra, reusable).
  • A dedicated ProductsModulecontrollers: [ProductsController], providers: [ProductsService], imports: [PrismaModule].

Also consider marking PrismaModule as @Global() if every feature module will import it, so you don't have to add it to each imports array.

🔧 Suggested shape
 import { Module } from '@nestjs/common';
 import { PrismaService } from './prisma.service';
-import { PrismaController } from './prisma.controller';

+@Global()
 `@Module`({
-  controllers: [PrismaController],
   providers: [PrismaService],
   exports: [PrismaService],
 })
 export class PrismaModule {}

(and move the controller to a new ProductsModule).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/prisma/prisma.module.ts` around lines 1 - 10, PrismaModule currently
mixes infra and feature concerns: remove PrismaController from PrismaModule so
PrismaModule only provides and exports PrismaService (keep providers:
[PrismaService] and exports: [PrismaService]) and optionally mark PrismaModule
with `@Global`() if you want it available app-wide; create a new ProductsModule
that registers PrismaController (rename/move PrismaController to
ProductsController if appropriate) and its feature provider ProductsService, and
import PrismaModule into ProductsModule (ProductsModule: controllers:
[ProductsController], providers: [ProductsService], imports: [PrismaModule]);
ensure any modules that used PrismaController now import ProductsModule instead.

18 changes: 18 additions & 0 deletions src/prisma/prisma.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { PrismaService } from './prisma.service';

describe('PrismaService', () => {
let service: PrismaService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [PrismaService],
}).compile();

service = module.get<PrismaService>(PrismaService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
Loading
Loading