Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
172274b8
Commit
172274b8
authored
Jul 06, 2023
by
Jeffrey Morgan
Browse files
fix auto update route
parent
7bf3212c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
web/app/api/update/route.ts
web/app/api/update/route.ts
+7
-3
No files found.
web/app/api/update/route.ts
View file @
172274b8
...
...
@@ -11,6 +11,10 @@ export async function GET(req: Request) {
const
os
=
searchParams
.
get
(
'
os
'
)
||
''
const
version
=
searchParams
.
get
(
'
version
'
)
||
''
if
(
!
version
)
{
return
new
Response
(
'
not found
'
,
{
status
:
404
})
}
try
{
const
{
data
}
=
await
octokit
.
repos
.
getLatestRelease
({
owner
:
'
jmorganca
'
,
...
...
@@ -21,12 +25,14 @@ export async function GET(req: Request) {
const
asset
=
data
.
assets
.
find
(
a
=>
a
.
name
.
toLowerCase
().
includes
(
os
))
if
(
!
asset
)
{
return
new
Response
(
'
up to date
'
,
{
status
:
2
04
})
return
new
Response
(
'
not found
'
,
{
status
:
4
04
})
}
if
(
semver
.
lt
(
version
,
data
.
tag_name
))
{
return
NextResponse
.
json
({
version
:
data
.
tag_name
,
url
:
asset
.
browser_download_url
})
}
return
new
Response
(
'
up to date
'
,
{
status
:
204
})
}
catch
(
error
)
{
const
e
=
error
as
RequestError
if
(
e
.
status
===
404
)
{
...
...
@@ -35,6 +41,4 @@ export async function GET(req: Request) {
return
new
Response
(
'
internal server error
'
,
{
status
:
500
})
}
return
new
Response
(
'
up to date
'
,
{
status
:
204
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment