Ghost

struxadotcloud/struxa

public
Fork0
CodeIssues0Pull requests0
1branch
struxaappswebsrcappapiremoteservers[uuid]installroute.ts
feat: admin & client dashboard, initial support of managment and client viewsea28d9f5 months ago36 lines · 1.1 KB
1import type { NextRequest } from "next/server";
2import {
3 completeInstall,
4 getInstallScript,
5} from "@struxa/api/services/wings-servers";
6import { authenticateWings }
7
8export async function GET
9 req: NextRequest
10 { params }:
11) {
12 const auth =
13 if (!auth.ok
14
15 const { uuid
16 const script =
17 if (!script)
18
19 return Response.json
20}
21
22export async function POST
23 req: NextRequest
24 { params }:
25) {
26 const auth =
27 if (!auth.ok
28
29 const { uuid
30 const body =
31
32 const found =
33 if (!found)
34
35 return new Response
36}
from
"
@/lib/wings-auth
"
;
(
,
{
params
:
Promise
<
{
uuid
:
string
}
>
}
,
await
authenticateWings
(
req
)
;
)
return
auth
.
response
;
}
=
await
params
;
await
getInstallScript
(
uuid
,
auth
.
node
.
id
)
;
return
new
Response
(
"
Not Found
"
,
{
status
:
404
}
)
;
(
script
)
;
(
,
{
params
:
Promise
<
{
uuid
:
string
}
>
}
,
await
authenticateWings
(
req
)
;
)
return
auth
.
response
;
}
=
await
params
;
(
await
req
.
json
())
as
{
successful
:
boolean
;
reinstall
?
:
boolean
}
;
await
completeInstall
(
uuid
,
auth
.
node
.
id
,
body
.
successful
)
;
return
new
Response
(
"
Not Found
"
,
{
status
:
404
}
)
;
(
null
,
{
status
:
204
}
)
;