feat(lstmobile): intial scanner setup kinda working
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m7s
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m7s
This commit is contained in:
49
backend/system/system.mobileApp.ts
Normal file
49
backend/system/system.mobileApp.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import fs from "node:fs";
|
||||
import { Router } from "express";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const router = Router();
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const downloadDir = path.resolve(__dirname, "../../downloads/mobile");
|
||||
|
||||
const currentApk = {
|
||||
packageName: "net.alpla.lst.mobile",
|
||||
versionName: "0.0.1-alpha",
|
||||
versionCode: 1,
|
||||
minSupportedVersionCode: 1,
|
||||
fileName: "lst-mobile.apk",
|
||||
};
|
||||
|
||||
router.get("/version", async (req, res) => {
|
||||
const baseUrl = `${req.protocol}://${req.get("host")}`;
|
||||
|
||||
res.json({
|
||||
packageName: currentApk.packageName,
|
||||
versionName: currentApk.versionName,
|
||||
versionCode: currentApk.versionCode,
|
||||
minSupportedVersionCode: currentApk.minSupportedVersionCode,
|
||||
downloadUrl: `${baseUrl}/lst/api/mobile/apk/latest`,
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/apk/latest", (_, res) => {
|
||||
const apkPath = path.join(downloadDir, currentApk.fileName);
|
||||
|
||||
if (!fs.existsSync(apkPath)) {
|
||||
return res.status(404).json({ success: false, message: "APK not found" });
|
||||
}
|
||||
|
||||
res.setHeader("Content-Type", "application/vnd.android.package-archive");
|
||||
res.setHeader(
|
||||
"Content-Disposition",
|
||||
`attachment; filename="${currentApk.fileName}"`,
|
||||
);
|
||||
|
||||
return res.sendFile(apkPath);
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -3,10 +3,12 @@ import { requireAuth } from "../middleware/auth.middleware.js";
|
||||
import getSettings from "./settings.route.js";
|
||||
import updSetting from "./settingsUpdate.route.js";
|
||||
import stats from "./stats.route.js";
|
||||
import mobile from "./system.mobileApp.js";
|
||||
|
||||
export const setupSystemRoutes = (baseUrl: string, app: Express) => {
|
||||
//stats will be like this as we dont need to change this
|
||||
app.use(`${baseUrl}/api/stats`, stats);
|
||||
app.use(`${baseUrl}/api/mobile`, mobile);
|
||||
app.use(`${baseUrl}/api/settings`, getSettings);
|
||||
app.use(`${baseUrl}/api/settings`, requireAuth, updSetting);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ export const allowedOrigins = [
|
||||
"http://localhost:4000",
|
||||
"http://localhost:4001",
|
||||
"http://localhost:5500",
|
||||
"http://localhost:8081",
|
||||
"https://admin.socket.io",
|
||||
"https://electron-socket-io-playground.vercel.app",
|
||||
`${process.env.URL}`,
|
||||
|
||||
Reference in New Issue
Block a user