Ghost
New
pippinmole
/
ghost
public
forked from
ghost/ghost
Source code of Ghost - On Ghost
Star
0
Fork
0
Code
Issues
0
Pull requests
0
main
76
branches
Go to file
t
Code
ghost
apps
web
src
components
search
actions.ts
web: send server actions through the server API client, and define the action client once
a57e4b8
5 days ago
21 lines · 589 B
1
"
use server
"
;
2
3
import
{
actionClient
}
from
4
import
{
z
}
5
6
import
{
searchCode
}
7
8
export
const
loadCodeSearchPage
=
9
.
inputSchema
(
10
z
.
object
(
{
11
query
:
z
.
string
12
cursor
:
z
.
string
13
repository
:
z
.
object
14
}
)
,
15
)
16
.
action
(
async
(
17
const
{
data
,
18
if
(
error
)
throw
19
20
return
{
files
:
21
}
)
;
"
@/lib/action-client
"
;
from
"
zod
"
;
from
"
@/lib/api/code-search
"
;
actionClient
()
.
min
(
1
)
,
()
,
(
{
owner
:
z
.
string
()
,
slug
:
z
.
string
()
}
)
.
optional
()
,
{
parsedInput
}
)
=>
{
error
}
=
await
searchCode
(
parsedInput
)
;
new
Error
(
error
.
message
)
;
data
.
files
,
nextCursor
:
data
.
nextCursor
}
;