Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csn-groupthink
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bom, David Jonathan
csn-groupthink
Commits
64184791
Commit
64184791
authored
1 year ago
by
daef
Browse files
Options
Downloads
Patches
Plain Diff
seems2work
parent
7283e2d1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docker-compose.yml
+7
-7
7 additions, 7 deletions
docker-compose.yml
todo_app/src/server/api/routers/todo.ts
+20
-31
20 additions, 31 deletions
todo_app/src/server/api/routers/todo.ts
with
27 additions
and
38 deletions
docker-compose.yml
+
7
−
7
View file @
64184791
...
...
@@ -7,12 +7,12 @@ services:
ports
:
-
50051:50051
trpc-todo-app
:
build
:
context
:
./todo_app
image
:
trpc-todo-app
container_name
:
trpc-todo-app
ports
:
-
3000:3000
#
trpc-todo-app:
#
build:
#
context: ./todo_app
#
image: trpc-todo-app
#
container_name: trpc-todo-app
#
ports:
#
- 3000:3000
This diff is collapsed.
Click to expand it.
todo_app/src/server/api/routers/todo.ts
+
20
−
31
View file @
64184791
...
...
@@ -2,33 +2,28 @@ import { z } from "zod";
// import { promisify } from "util";
import
{
createTRPCRouter
,
publicProcedure
}
from
"
~/server/api/trpc
"
type
Todo
=
{
id
:
number
,
text
:
string
,
done
:
boolean
,
imgid
?:
number
,
img
?:
string
}
type
Todo
=
{
id
:
number
,
text
:
string
,
done
:
boolean
,
img
?:
string
}
import
{
imageServiceClient
}
from
"
../grpc/utils
"
const
testGrpc
=
async
()
=>
{
const
compressMeBB
=
async
(
b64
)
=>
{
return
new
Promise
(
returrrn
=>
{
try
{
// doesnt work for some reason
// const putImage = promisify(imageServiceClient.PutImage);
// const getImage = promisify(imageServiceClient.GetImage);
const
originalImage
=
`/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAsACwDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDzKobj7o+tTVDcfdH1oArjpRQOlFABRRRQBeqG4+6PrU1Q3H3R9aAK46UUDpRQAUUUUAXqhuPuj61NUNx90fWgCuOlFA6UUAFFFFAH/9k=`
;
imageServiceClient
.
PutImage
({
'
image
'
:
originalImage
},
(
err
,
res
)
=>
{
console
.
log
(
"
gotten id
"
,
res
?.
id
);
console
.
log
(
"
getting back image
"
,
res
?.
id
);
console
.
log
(
'
original size
'
,
b64
.
length
)
imageServiceClient
.
PutImage
({
'
image
'
:
b64
},
(
err
,
res
)
=>
{
console
.
log
(
"
imgsrv id
"
,
res
?.
id
)
imageServiceClient
.
GetImage
({
'
id
'
:
res
?.
id
},
(
err
,
res1
)
=>
{
console
.
log
(
"
got image back
"
,
res1
?.
image
);
const
img
=
res1
?.
image
console
.
log
(
'
result size
'
,
img
?.
length
)
returrrn
(
img
)
})
})
}
catch
(
err
)
{
console
.
log
(
err
)
}
};
})
}
const
todos
:
Todo
[]
=
[
{
id
:
1
,
text
:
'
create trpc todo app
'
,
done
:
true
},
...
...
@@ -40,9 +35,7 @@ export const todoRouter = createTRPCRouter({
create
:
publicProcedure
.
input
(
z
.
object
({
text
:
z
.
string
().
min
(
1
)
}))
.
mutation
(
async
({
input
})
=>
{
const
todo
=
{
id
:
todos
.
length
+
1
,
text
:
input
.
text
,
done
:
false
,
imgid
:
undefined
,
img
:
undefined
}
//const todo = { id: todos.length + 1, text: input.text, done: false }
testGrpc
();
const
todo
=
{
id
:
todos
.
length
+
1
,
text
:
input
.
text
,
done
:
false
,
img
:
undefined
}
todos
.
push
(
todo
)
return
todo
}),
...
...
@@ -51,13 +44,9 @@ export const todoRouter = createTRPCRouter({
.
input
(
z
.
object
({
id
:
z
.
number
().
int
(),
img
:
z
.
string
()
}))
.
mutation
(
async
({
input
})
=>
{
const
found
=
todos
.
filter
((
t
)
=>
t
.
id
===
input
.
id
)
console
.
log
(
input
)
if
(
found
.
length
!=
1
||
found
[
0
]
===
undefined
)
return
// should go roundtrip via grpc svc first
// found[0].imgid = ???
found
[
0
].
img
=
input
.
img
console
.
log
(
todos
)
found
[
0
].
img
=
await
compressMeBB
(
input
.
img
)
}),
query
:
publicProcedure
...
...
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