Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NoteDiary_Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Дмитрий Малюгин
NoteDiary_Backend
Commits
fe37ed50
Commit
fe37ed50
authored
7 months ago
by
Дмитрий Малюгин
Browse files
Options
Downloads
Patches
Plain Diff
started trying to fix url size
parent
467d1db0
No related branches found
No related tags found
1 merge request
!2
Refactor/image and text
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env
+6
-2
6 additions, 2 deletions
.env
prisma/schema.prisma
+5
-3
5 additions, 3 deletions
prisma/schema.prisma
services/homeService.js
+15
-1
15 additions, 1 deletion
services/homeService.js
with
26 additions
and
6 deletions
.env
+
6
−
2
View file @
fe37ed50
...
...
@@ -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"
This diff is collapsed.
Click to expand it.
prisma/schema.prisma
+
5
−
3
View file @
fe37ed50
...
...
@@ -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"
}
...
...
@@ -12,6 +11,8 @@ generator client {
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
// при запуске с рабочего ноутбука
directUrl = env("DIRECT_URL")
}
model User {
...
...
@@ -34,13 +35,14 @@ model Home_entity {
entity_type String
title String?
text String? @db.Text
tex
t_size String?
fon
t_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?
...
...
This diff is collapsed.
Click to expand it.
services/homeService.js
+
15
−
1
View file @
fe37ed50
import
{
PrismaClient
}
from
'
@prisma/client
'
;
import
*
as
fs
from
'
node:fs
'
;
import
path
from
'
node:path
'
;
const
prisma
=
new
PrismaClient
();
...
...
@@ -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
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment