mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
added autoupdate endpoints
This commit is contained in:
parent
3f1010e5e4
commit
35a4f42766
@ -6,7 +6,7 @@
|
||||
"webDir": "dist",
|
||||
"plugins": {
|
||||
"CapacitorUpdater": {
|
||||
"updateUrl": "https://relic.ragestudio.net/comty/update_check"
|
||||
"updateUrl": "https://api.comty.app/auto-update/mobile"
|
||||
}
|
||||
}
|
||||
}
|
46
packages/server/src/controllers/AutoUpdate/index.js
Normal file
46
packages/server/src/controllers/AutoUpdate/index.js
Normal file
@ -0,0 +1,46 @@
|
||||
import { Controller } from "linebridge/dist/server"
|
||||
|
||||
import { Octokit } from "@octokit/rest"
|
||||
|
||||
const octokit = new Octokit({})
|
||||
|
||||
const endpoints = {
|
||||
post: {
|
||||
"/mobile": {
|
||||
fn: async (req, res) => {
|
||||
if (!process.env.GITHUB_REPO) {
|
||||
return res.status(400).json({
|
||||
error: "GITHUB_REPO env variable not set"
|
||||
})
|
||||
}
|
||||
|
||||
const lastRelease = await octokit.repos.getLatestRelease({
|
||||
owner: process.env.GITHUB_REPO.split("/")[0],
|
||||
repo: process.env.GITHUB_REPO.split("/")[1]
|
||||
})
|
||||
|
||||
const bundle = lastRelease.data.assets.find((asset) => asset.name === "mobile_dist.zip")
|
||||
const version = lastRelease.data.tag_name
|
||||
|
||||
if (!bundle) {
|
||||
return res.status(400).json({
|
||||
error: "mobile asset not available",
|
||||
version: version,
|
||||
})
|
||||
}
|
||||
|
||||
return res.json({
|
||||
url: bundle.browser_download_url,
|
||||
version: version,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default class AutoUpdate extends Controller {
|
||||
static refName = "AutoUpdate"
|
||||
static useRoute = "/auto-update"
|
||||
|
||||
httpEndpoints = endpoints
|
||||
}
|
@ -24,4 +24,6 @@ export { default as ModerationController } from "./ModerationController"
|
||||
|
||||
export { default as AdminController } from "./AdminController"
|
||||
|
||||
export { default as SyncController } from "./SyncController"
|
||||
export { default as SyncController } from "./SyncController"
|
||||
|
||||
export { default as AutoUpdateController } from "./AutoUpdate"
|
Loading…
x
Reference in New Issue
Block a user