Loading .env +6 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,10 @@ DB_USER=postgres DB_PASSWORD=xoxo2002! DB_HOST=localhost DB_PORT=5432 // prisma db push ; при запуске с родного ноутбука ; DATABASE_URL="postgresql://postgres:xoxo2002!@localhost:5432/Shelf_note" DATABASE_URL="postgresql://postgres:xoxo2002!@localhost:5432/Shelf_note" ; при запуске с рабочего ноутбука DATABASE_URL="postgresql://postgres.wrwwvdgppriodcdoyohp:Xoxo2002!qwe@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true" DIRECT_URL="postgresql://postgres.wrwwvdgppriodcdoyohp:Xoxo2002!qwe@aws-0-eu-central-1.pooler.supabase.com:5432/postgres" prisma/schema.prisma +5 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init // prisma db push generator client { provider = "prisma-client-js" } Loading @@ -12,6 +11,8 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") // при запуске с рабочего ноутбука directUrl = env("DIRECT_URL") } model User { Loading @@ -34,13 +35,14 @@ model Home_entity { entity_type String title String? text String? @db.Text text_size String? font_size String? paragraph_size String? text_position String? image_url String? @db.Text image_width Int? image_height Int? image_position String? entity_position String? entity_title_position String? image_scale String? table_columns Json? table_data Json? Loading services/homeService.js +15 −1 Original line number Diff line number Diff line import { PrismaClient } from '@prisma/client'; import * as fs from 'node:fs'; import path from 'node:path'; const prisma = new PrismaClient(); Loading @@ -16,7 +18,19 @@ class HomeService { }); } async createEntity(body) { return prisma.home_entity.create({ data: body }); let pathOfImage = ''; if (body.image_url) { console.log('body.image_url', body.image_url); // const response = await fetch(body.image_url); // const blob = await body.image_url.blob(); const arrayBuffer = new ArrayBuffer(body.image_url); // const arrayBuffer = await body.image_url.arrayBuffer(); const buffer = Buffer.from(arrayBuffer); pathOfImage = path.join(path.resolve(), `/public/images/${body.entity_uuid}`); console.log('pathOfImage', pathOfImage); fs.writeFile(pathOfImage, buffer, () => console.log('Written!')); } return prisma.home_entity.create({ data: { ...body, image_url: pathOfImage } }); } async editEntity(body) { return prisma.home_entity.update({ Loading Loading
.env +6 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,10 @@ DB_USER=postgres DB_PASSWORD=xoxo2002! DB_HOST=localhost DB_PORT=5432 // prisma db push ; при запуске с родного ноутбука ; DATABASE_URL="postgresql://postgres:xoxo2002!@localhost:5432/Shelf_note" DATABASE_URL="postgresql://postgres:xoxo2002!@localhost:5432/Shelf_note" ; при запуске с рабочего ноутбука DATABASE_URL="postgresql://postgres.wrwwvdgppriodcdoyohp:Xoxo2002!qwe@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true" DIRECT_URL="postgresql://postgres.wrwwvdgppriodcdoyohp:Xoxo2002!qwe@aws-0-eu-central-1.pooler.supabase.com:5432/postgres"
prisma/schema.prisma +5 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init // prisma db push generator client { provider = "prisma-client-js" } Loading @@ -12,6 +11,8 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") // при запуске с рабочего ноутбука directUrl = env("DIRECT_URL") } model User { Loading @@ -34,13 +35,14 @@ model Home_entity { entity_type String title String? text String? @db.Text text_size String? font_size String? paragraph_size String? text_position String? image_url String? @db.Text image_width Int? image_height Int? image_position String? entity_position String? entity_title_position String? image_scale String? table_columns Json? table_data Json? Loading
services/homeService.js +15 −1 Original line number Diff line number Diff line import { PrismaClient } from '@prisma/client'; import * as fs from 'node:fs'; import path from 'node:path'; const prisma = new PrismaClient(); Loading @@ -16,7 +18,19 @@ class HomeService { }); } async createEntity(body) { return prisma.home_entity.create({ data: body }); let pathOfImage = ''; if (body.image_url) { console.log('body.image_url', body.image_url); // const response = await fetch(body.image_url); // const blob = await body.image_url.blob(); const arrayBuffer = new ArrayBuffer(body.image_url); // const arrayBuffer = await body.image_url.arrayBuffer(); const buffer = Buffer.from(arrayBuffer); pathOfImage = path.join(path.resolve(), `/public/images/${body.entity_uuid}`); console.log('pathOfImage', pathOfImage); fs.writeFile(pathOfImage, buffer, () => console.log('Written!')); } return prisma.home_entity.create({ data: { ...body, image_url: pathOfImage } }); } async editEntity(body) { return prisma.home_entity.update({ Loading