FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencode/packages/opencode/test/server/httpapi-layer.ts at dev · argszero/opencode · GitHub
argszero
/
opencode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencode
/
packages
/
opencode
/
test
/
server
/
httpapi-layer.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (29 loc) · 1.19 KB
Breadcrumbs
opencode
/
packages
/
opencode
/
test
/
server
/
httpapi-layer.ts
Copy path
File metadata and controls
33 lines (29 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import
{
NodeHttpServer
,
NodeServices
}
from
"@effect/platform-node"
import
{
Config
,
Layer
}
from
"effect"
import
{
HttpClient
,
HttpClientRequest
,
HttpRouter
,
HttpServer
}
from
"effect/unstable/http"
import
{
layerWebSocketConstructorGlobal
}
from
"effect/unstable/socket/Socket"
import
{
HttpApiApp
}
from
"../../src/server/routes/instance/httpapi/server"
const
servedRoutes
:
Layer
.
Layer
<
never
,
Config
.
ConfigError
,
HttpServer
.
HttpServer
>
=
HttpRouter
.
serve
(
HttpApiApp
.
routes
,
{
disableListenLog
:
true
,
disableLogger
:
true
,
}
,
)
export
const
httpApiLayer
=
servedRoutes
.
pipe
(
Layer
.
provide
(
layerWebSocketConstructorGlobal
)
,
Layer
.
provideMerge
(
NodeHttpServer
.
layerTest
)
,
Layer
.
provideMerge
(
NodeServices
.
layer
)
,
)
export
function
request
(
path
:
string
,
init
?:
RequestInit
)
{
const
url
=
new
URL
(
path
,
"http://localhost"
)
return
HttpClientRequest
.
fromWeb
(
new
Request
(
url
,
init
)
)
.
pipe
(
HttpClientRequest
.
setUrl
(
url
.
pathname
)
,
HttpClient
.
execute
,
)
}
export
function
requestInDirectory
(
path
:
string
,
directory
:
string
,
init
:
RequestInit
=
{
}
)
{
const
headers
=
new
Headers
(
init
.
headers
)
headers
.
set
(
"x-opencode-directory"
,
directory
)
return
request
(
path
,
{
...
init
,
headers
}
)
}
Back
|
FazBrowse Home
|
New Git URL