├── src ├── reviews │ ├── entities │ │ └── review.entity.ts │ ├── dto │ │ ├── create-review.dto.ts │ │ └── update-review.dto.ts │ ├── reviews.module.ts │ ├── reviews.service.spec.ts │ ├── reviews.controller.spec.ts │ ├── reviews.service.ts │ └── reviews.controller.ts ├── app.service.ts ├── main.ts ├── database │ ├── database.module.ts │ ├── database.service.ts │ └── database.service.spec.ts ├── products │ ├── products.module.ts │ ├── products.service.spec.ts │ ├── products.controller.spec.ts │ ├── products.controller.ts │ └── products.service.ts ├── app.controller.ts ├── app.module.ts └── app.controller.spec.ts ├── .prettierrc ├── tsconfig.build.json ├── docker-compose.yaml ├── prisma ├── migrations │ ├── migration_lock.toml │ ├── 20231011220759_init │ │ └── migration.sql │ └── 20231015213738_relations │ │ └── migration.sql └── schema.prisma ├── nest-cli.json ├── test ├── jest-e2e.json └── app.e2e-spec.ts ├── .gitignore ├── .env ├── tsconfig.json ├── .eslintrc.js ├── package.json └── README.md /src/reviews/entities/review.entity.ts: -------------------------------------------------------------------------------- 1 | export class Review {} 2 | -------------------------------------------------------------------------------- /src/reviews/dto/create-review.dto.ts: -------------------------------------------------------------------------------- 1 | export class CreateReviewDto {} 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | mysql: 3 | image: mysql 4 | env_file: 5 | - .env 6 | ports: 7 | - '3306:3306' 8 | -------------------------------------------------------------------------------- /prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "mysql" -------------------------------------------------------------------------------- /src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/reviews/dto/update-review.dto.ts: -------------------------------------------------------------------------------- 1 | import { PartialType } from '@nestjs/mapped-types'; 2 | import { CreateReviewDto } from './create-review.dto'; 3 | 4 | export class UpdateReviewDto extends PartialType(CreateReviewDto) {} 5 | -------------------------------------------------------------------------------- /test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /src/database/database.module.ts: -------------------------------------------------------------------------------- 1 | import { Global, Module } from '@nestjs/common'; 2 | import { DatabaseService } from './database.service'; 3 | 4 | @Global() 5 | @Module({ 6 | providers: [DatabaseService], 7 | exports: [DatabaseService], 8 | }) 9 | export class DatabaseModule {} 10 | -------------------------------------------------------------------------------- /src/database/database.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, OnModuleInit } from '@nestjs/common'; 2 | import { PrismaClient } from '@prisma/client'; 3 | 4 | @Injectable() 5 | export class DatabaseService extends PrismaClient implements OnModuleInit { 6 | async onModuleInit() { 7 | await this.$connect(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/reviews/reviews.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ReviewsService } from './reviews.service'; 3 | import { ReviewsController } from './reviews.controller'; 4 | 5 | @Module({ 6 | controllers: [ReviewsController], 7 | providers: [ReviewsService], 8 | }) 9 | export class ReviewsModule {} 10 | -------------------------------------------------------------------------------- /src/products/products.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ProductsService } from './products.service'; 3 | import { ProductsController } from './products.controller'; 4 | 5 | @Module({ 6 | controllers: [ProductsController], 7 | providers: [ProductsService], 8 | }) 9 | export class ProductsModule {} 10 | -------------------------------------------------------------------------------- /src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | import { DatabaseModule } from './database/database.module'; 5 | import { ProductsModule } from './products/products.module'; 6 | import { ReviewsModule } from './reviews/reviews.module'; 7 | 8 | @Module({ 9 | imports: [DatabaseModule, ProductsModule, ReviewsModule], 10 | controllers: [AppController], 11 | providers: [AppService], 12 | }) 13 | export class AppModule {} 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | pnpm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # OS 15 | .DS_Store 16 | 17 | # Tests 18 | /coverage 19 | /.nyc_output 20 | 21 | # IDEs and editors 22 | /.idea 23 | .project 24 | .classpath 25 | .c9/ 26 | *.launch 27 | .settings/ 28 | *.sublime-workspace 29 | 30 | # IDE - VSCode 31 | .vscode/* 32 | !.vscode/settings.json 33 | !.vscode/tasks.json 34 | !.vscode/launch.json 35 | !.vscode/extensions.json -------------------------------------------------------------------------------- /src/reviews/reviews.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ReviewsService } from './reviews.service'; 3 | 4 | describe('ReviewsService', () => { 5 | let service: ReviewsService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [ReviewsService], 10 | }).compile(); 11 | 12 | service = module.get(ReviewsService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /prisma/migrations/20231011220759_init/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE `Product` ( 3 | `id` INTEGER NOT NULL AUTO_INCREMENT, 4 | `name` VARCHAR(191) NOT NULL, 5 | `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), 6 | `updatedAt` DATETIME(3) NOT NULL, 7 | `price` DOUBLE NOT NULL, 8 | `sale` BOOLEAN NOT NULL DEFAULT false, 9 | `availibility` ENUM('IN_STORE', 'ONLINE') NOT NULL, 10 | 11 | UNIQUE INDEX `Product_name_key`(`name`), 12 | PRIMARY KEY (`id`) 13 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 14 | -------------------------------------------------------------------------------- /src/database/database.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { DatabaseService } from './database.service'; 3 | 4 | describe('DatabaseService', () => { 5 | let service: DatabaseService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [DatabaseService], 10 | }).compile(); 11 | 12 | service = module.get(DatabaseService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /src/products/products.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ProductsService } from './products.service'; 3 | 4 | describe('ProductsService', () => { 5 | let service: ProductsService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [ProductsService], 10 | }).compile(); 11 | 12 | service = module.get(ProductsService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # Environment variables declared in this file are automatically made available to Prisma. 2 | # See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema 3 | 4 | # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. 5 | # See the documentation for all the connection string options: https://pris.ly/d/connection-strings 6 | 7 | DATABASE_URL="mysql://root:password@127.0.0.1:3306/nestjs_prisma" 8 | 9 | MYSQL_DATABASE=nestjs_prisma 10 | MYSQL_ROOT_PASSWORD=password -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "ES2021", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/reviews/reviews.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ReviewsController } from './reviews.controller'; 3 | import { ReviewsService } from './reviews.service'; 4 | 5 | describe('ReviewsController', () => { 6 | let controller: ReviewsController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [ReviewsController], 11 | providers: [ReviewsService], 12 | }).compile(); 13 | 14 | controller = module.get(ReviewsController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /src/products/products.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { ProductsController } from './products.controller'; 3 | import { ProductsService } from './products.service'; 4 | 5 | describe('ProductsController', () => { 6 | let controller: ProductsController; 7 | 8 | beforeEach(async () => { 9 | const module: TestingModule = await Test.createTestingModule({ 10 | controllers: [ProductsController], 11 | providers: [ProductsService], 12 | }).compile(); 13 | 14 | controller = module.get(ProductsController); 15 | }); 16 | 17 | it('should be defined', () => { 18 | expect(controller).toBeDefined(); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /src/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppController', () => { 6 | let appController: AppController; 7 | 8 | beforeEach(async () => { 9 | const app: TestingModule = await Test.createTestingModule({ 10 | controllers: [AppController], 11 | providers: [AppService], 12 | }).compile(); 13 | 14 | appController = app.get(AppController); 15 | }); 16 | 17 | describe('root', () => { 18 | it('should return "Hello World!"', () => { 19 | expect(appController.getHello()).toBe('Hello World!'); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /test/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { INestApplication } from '@nestjs/common'; 3 | import * as request from 'supertest'; 4 | import { AppModule } from './../src/app.module'; 5 | 6 | describe('AppController (e2e)', () => { 7 | let app: INestApplication; 8 | 9 | beforeEach(async () => { 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); 13 | 14 | app = moduleFixture.createNestApplication(); 15 | await app.init(); 16 | }); 17 | 18 | it('/ (GET)', () => { 19 | return request(app.getHttpServer()) 20 | .get('/') 21 | .expect(200) 22 | .expect('Hello World!'); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | tsconfigRootDir: __dirname, 6 | sourceType: 'module', 7 | }, 8 | plugins: ['@typescript-eslint/eslint-plugin'], 9 | extends: [ 10 | 'plugin:@typescript-eslint/recommended', 11 | 'plugin:prettier/recommended', 12 | ], 13 | root: true, 14 | env: { 15 | node: true, 16 | jest: true, 17 | }, 18 | ignorePatterns: ['.eslintrc.js'], 19 | rules: { 20 | '@typescript-eslint/interface-name-prefix': 'off', 21 | '@typescript-eslint/explicit-function-return-type': 'off', 22 | '@typescript-eslint/explicit-module-boundary-types': 'off', 23 | '@typescript-eslint/no-explicit-any': 'off', 24 | }, 25 | }; 26 | -------------------------------------------------------------------------------- /src/reviews/reviews.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { DatabaseService } from '../database/database.service'; 3 | import { Prisma } from '@prisma/client'; 4 | 5 | @Injectable() 6 | export class ReviewsService { 7 | constructor(private readonly databaseService: DatabaseService) {} 8 | 9 | async create(createReviewDto: Prisma.ReviewCreateInput) { 10 | return this.databaseService.review.create({ data: createReviewDto }); 11 | } 12 | 13 | async findAll() { 14 | return this.databaseService.review.findMany({}); 15 | } 16 | 17 | async findOne(id: number) { 18 | return this.databaseService.review.findUnique({ 19 | where: { 20 | id, 21 | }, 22 | }); 23 | } 24 | 25 | async update(id: number, updateReviewDto: Prisma.ReviewUpdateInput) { 26 | return this.databaseService.review.update({ 27 | where: { 28 | id, 29 | }, 30 | data: updateReviewDto, 31 | }); 32 | } 33 | 34 | async remove(id: number) { 35 | return this.databaseService.review.delete({ 36 | where: { id }, 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/reviews/reviews.controller.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Controller, 3 | Get, 4 | Post, 5 | Body, 6 | Patch, 7 | Param, 8 | Delete, 9 | } from '@nestjs/common'; 10 | import { ReviewsService } from './reviews.service'; 11 | import { Prisma } from '@prisma/client'; 12 | 13 | @Controller('reviews') 14 | export class ReviewsController { 15 | constructor(private readonly reviewsService: ReviewsService) {} 16 | 17 | @Post() 18 | create(@Body() createReviewDto: Prisma.ReviewCreateInput) { 19 | return this.reviewsService.create(createReviewDto); 20 | } 21 | 22 | @Get() 23 | findAll() { 24 | return this.reviewsService.findAll(); 25 | } 26 | 27 | @Get(':id') 28 | findOne(@Param('id') id: string) { 29 | return this.reviewsService.findOne(+id); 30 | } 31 | 32 | @Patch(':id') 33 | update( 34 | @Param('id') id: string, 35 | @Body() updateReviewDto: Prisma.ReviewUpdateInput, 36 | ) { 37 | return this.reviewsService.update(+id, updateReviewDto); 38 | } 39 | 40 | @Delete(':id') 41 | remove(@Param('id') id: string) { 42 | return this.reviewsService.remove(+id); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/products/products.controller.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Controller, 3 | Get, 4 | Post, 5 | Body, 6 | Patch, 7 | Param, 8 | Delete, 9 | } from '@nestjs/common'; 10 | import { ProductsService } from './products.service'; 11 | import { Prisma } from '@prisma/client'; 12 | 13 | @Controller('products') 14 | export class ProductsController { 15 | constructor(private readonly productsService: ProductsService) {} 16 | 17 | @Post() 18 | create(@Body() createProductDto: Prisma.ProductCreateInput) { 19 | return this.productsService.create(createProductDto); 20 | } 21 | 22 | @Get() 23 | findAll() { 24 | return this.productsService.findAll(); 25 | } 26 | 27 | @Get(':id') 28 | findOne(@Param('id') id: string) { 29 | return this.productsService.findOne(+id); 30 | } 31 | 32 | @Patch(':id') 33 | update( 34 | @Param('id') id: string, 35 | @Body() updateProductDto: Prisma.ProductUpdateInput, 36 | ) { 37 | return this.productsService.update(+id, updateProductDto); 38 | } 39 | 40 | @Delete(':id') 41 | remove(@Param('id') id: string) { 42 | return this.productsService.remove(+id); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | generator client { 5 | provider = "prisma-client-js" 6 | } 7 | 8 | datasource db { 9 | provider = "mysql" 10 | url = env("DATABASE_URL") 11 | } 12 | 13 | model Product { 14 | id Int @default(autoincrement()) @id 15 | name String @unique 16 | createdAt DateTime @default(now()) 17 | updatedAt DateTime @updatedAt 18 | price Float 19 | sale Boolean @default(false) 20 | availibility Availibility 21 | reviews Review[] 22 | tags Tag[] 23 | description Description? 24 | } 25 | 26 | model Description { 27 | id Int @default(autoincrement()) @id 28 | content String 29 | product Product @relation(fields: [productId], references: [id]) 30 | productId Int @unique 31 | } 32 | 33 | model Review { 34 | id Int @default(autoincrement()) @id 35 | title String 36 | content String 37 | rating Int 38 | product Product @relation(fields: [productId], references: [id]) 39 | productId Int 40 | } 41 | 42 | model Tag { 43 | id Int @default(autoincrement()) @id 44 | content String 45 | products Product[] 46 | } 47 | 48 | enum Availibility { 49 | IN_STORE 50 | ONLINE 51 | } -------------------------------------------------------------------------------- /src/products/products.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { DatabaseService } from '../database/database.service'; 3 | import { Prisma } from '@prisma/client'; 4 | 5 | @Injectable() 6 | export class ProductsService { 7 | constructor(private readonly databaseService: DatabaseService) {} 8 | 9 | async create(createProductDto: Prisma.ProductCreateInput) { 10 | return this.databaseService.product.create({ data: createProductDto }); 11 | } 12 | 13 | async findAll() { 14 | return this.databaseService.product.findMany({}); 15 | } 16 | 17 | async findOne(id: number) { 18 | return this.databaseService.product.findUnique({ 19 | where: { 20 | id, 21 | }, 22 | include: { 23 | description: true, 24 | tags: true, 25 | reviews: true, 26 | }, 27 | }); 28 | } 29 | 30 | async update(id: number, updateProductDto: Prisma.ProductUpdateInput) { 31 | return this.databaseService.product.update({ 32 | where: { 33 | id, 34 | }, 35 | data: updateProductDto, 36 | }); 37 | } 38 | 39 | async remove(id: number) { 40 | return this.databaseService.product.delete({ 41 | where: { id }, 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /prisma/migrations/20231015213738_relations/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE `Description` ( 3 | `id` INTEGER NOT NULL AUTO_INCREMENT, 4 | `content` VARCHAR(191) NOT NULL, 5 | `productId` INTEGER NOT NULL, 6 | 7 | UNIQUE INDEX `Description_productId_key`(`productId`), 8 | PRIMARY KEY (`id`) 9 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 10 | 11 | -- CreateTable 12 | CREATE TABLE `Review` ( 13 | `id` INTEGER NOT NULL AUTO_INCREMENT, 14 | `title` VARCHAR(191) NOT NULL, 15 | `content` VARCHAR(191) NOT NULL, 16 | `rating` INTEGER NOT NULL, 17 | `productId` INTEGER NOT NULL, 18 | 19 | PRIMARY KEY (`id`) 20 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 21 | 22 | -- CreateTable 23 | CREATE TABLE `Tag` ( 24 | `id` INTEGER NOT NULL AUTO_INCREMENT, 25 | `content` VARCHAR(191) NOT NULL, 26 | 27 | PRIMARY KEY (`id`) 28 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 29 | 30 | -- CreateTable 31 | CREATE TABLE `_ProductToTag` ( 32 | `A` INTEGER NOT NULL, 33 | `B` INTEGER NOT NULL, 34 | 35 | UNIQUE INDEX `_ProductToTag_AB_unique`(`A`, `B`), 36 | INDEX `_ProductToTag_B_index`(`B`) 37 | ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 38 | 39 | -- AddForeignKey 40 | ALTER TABLE `Description` ADD CONSTRAINT `Description_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; 41 | 42 | -- AddForeignKey 43 | ALTER TABLE `Review` ADD CONSTRAINT `Review_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; 44 | 45 | -- AddForeignKey 46 | ALTER TABLE `_ProductToTag` ADD CONSTRAINT `_ProductToTag_A_fkey` FOREIGN KEY (`A`) REFERENCES `Product`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; 47 | 48 | -- AddForeignKey 49 | ALTER TABLE `_ProductToTag` ADD CONSTRAINT `_ProductToTag_B_fkey` FOREIGN KEY (`B`) REFERENCES `Tag`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; 50 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nestjs-prisma", 3 | "version": "0.0.1", 4 | "description": "", 5 | "author": "", 6 | "private": true, 7 | "license": "UNLICENSED", 8 | "scripts": { 9 | "build": "nest build", 10 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 11 | "start": "nest start", 12 | "start:dev": "nest start --watch", 13 | "start:debug": "nest start --debug --watch", 14 | "start:prod": "node dist/main", 15 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", 16 | "test": "jest", 17 | "test:watch": "jest --watch", 18 | "test:cov": "jest --coverage", 19 | "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", 20 | "test:e2e": "jest --config ./test/jest-e2e.json" 21 | }, 22 | "dependencies": { 23 | "@nestjs/common": "^10.0.0", 24 | "@nestjs/core": "^10.0.0", 25 | "@nestjs/mapped-types": "*", 26 | "@nestjs/platform-express": "^10.0.0", 27 | "@prisma/client": "5.4.2", 28 | "reflect-metadata": "^0.1.13", 29 | "rxjs": "^7.8.1" 30 | }, 31 | "devDependencies": { 32 | "@nestjs/cli": "^10.0.0", 33 | "@nestjs/schematics": "^10.0.0", 34 | "@nestjs/testing": "^10.0.0", 35 | "@types/express": "^4.17.17", 36 | "@types/jest": "^29.5.2", 37 | "@types/node": "^20.3.1", 38 | "@types/supertest": "^2.0.12", 39 | "@typescript-eslint/eslint-plugin": "^6.0.0", 40 | "@typescript-eslint/parser": "^6.0.0", 41 | "eslint": "^8.42.0", 42 | "eslint-config-prettier": "^9.0.0", 43 | "eslint-plugin-prettier": "^5.0.0", 44 | "jest": "^29.5.0", 45 | "prettier": "^3.0.0", 46 | "prisma": "^5.4.2", 47 | "source-map-support": "^0.5.21", 48 | "supertest": "^6.3.3", 49 | "ts-jest": "^29.1.0", 50 | "ts-loader": "^9.4.3", 51 | "ts-node": "^10.9.1", 52 | "tsconfig-paths": "^4.2.0", 53 | "typescript": "^5.1.3" 54 | }, 55 | "jest": { 56 | "moduleFileExtensions": [ 57 | "js", 58 | "json", 59 | "ts" 60 | ], 61 | "rootDir": "src", 62 | "testRegex": ".*\\.spec\\.ts$", 63 | "transform": { 64 | "^.+\\.(t|j)s$": "ts-jest" 65 | }, 66 | "collectCoverageFrom": [ 67 | "**/*.(t|j)s" 68 | ], 69 | "coverageDirectory": "../coverage", 70 | "testEnvironment": "node" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Nest Logo 3 |

4 | 5 | [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 6 | [circleci-url]: https://circleci.com/gh/nestjs/nest 7 | 8 |

A progressive Node.js framework for building efficient and scalable server-side applications.

9 |

10 | NPM Version 11 | Package License 12 | NPM Downloads 13 | CircleCI 14 | Coverage 15 | Discord 16 | Backers on Open Collective 17 | Sponsors on Open Collective 18 | 19 | Support us 20 | 21 |

22 | 24 | 25 | ## Description 26 | 27 | [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. 28 | 29 | ## Installation 30 | 31 | ```bash 32 | $ pnpm install 33 | ``` 34 | 35 | ## Running the app 36 | 37 | ```bash 38 | # development 39 | $ pnpm run start 40 | 41 | # watch mode 42 | $ pnpm run start:dev 43 | 44 | # production mode 45 | $ pnpm run start:prod 46 | ``` 47 | 48 | ## Test 49 | 50 | ```bash 51 | # unit tests 52 | $ pnpm run test 53 | 54 | # e2e tests 55 | $ pnpm run test:e2e 56 | 57 | # test coverage 58 | $ pnpm run test:cov 59 | ``` 60 | 61 | ## Support 62 | 63 | Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). 64 | 65 | ## Stay in touch 66 | 67 | - Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) 68 | - Website - [https://nestjs.com](https://nestjs.com/) 69 | - Twitter - [@nestframework](https://twitter.com/nestframework) 70 | 71 | ## License 72 | 73 | Nest is [MIT licensed](LICENSE). 74 | --------------------------------------------------------------------------------