Skip to content

Commit

Permalink
feat(api): add status page
Browse files Browse the repository at this point in the history
resolves #239
  • Loading branch information
RaunoT committed Aug 26, 2024
1 parent bb12d06 commit 62c4c98
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ services:
> _NOTE: If you run into authentication issues, try setting `NEXTAUTH_URL` and `NEXT_PUBLIC_SITE_URL` to your external Docker IP, instead of localhost. For example `http://192.168.1.1:8383`._

For those that need it, a simple status page is also available at `/api/status`.

### Unraid

Plex Rewind is also available in the Community Apps store for Unraid. Search for "Plex Rewind" and install it from grtgbln's repository.
Expand Down
13 changes: 13 additions & 0 deletions src/app/api/status/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import getVersion from '@/utils/getVersion'

export const dynamic = 'force-dynamic'

export async function GET() {
const version = await getVersion()

return Response.json({
version: version.currentVersion,
channel: version.channel,
updateAvailable: version.hasUpdate,
})
}
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export type Version = {
hasUpdate: boolean
latestVersion: string
currentVersion: string
channel: 'develop' | 'stable' | 'local'
}
2 changes: 2 additions & 0 deletions src/utils/getVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default async function getVersion(): Promise<Version> {
const isSHA = /^[0-9a-f]{40}$/i.test(tag) // Check if tag is a 40-character SHA
const currentVersion = tag ? (isSHA ? tag : `v${tag}`) : 'local' // Prefix with 'v' if not a SHA
const isDevelop = currentVersion.includes('develop')
const channel = tag ? (isDevelop || isSHA ? 'develop' : 'stable') : 'local'

let latestVersion = currentVersion

Expand Down Expand Up @@ -55,5 +56,6 @@ export default async function getVersion(): Promise<Version> {
hasUpdate: latestVersion !== currentVersion,
latestVersion,
currentVersion,
channel,
}
}

0 comments on commit 62c4c98

Please sign in to comment.