upd
This commit is contained in:
+26
-10
@@ -6,7 +6,7 @@ import os from "os";
|
||||
import cron from "node-cron";
|
||||
import { exec, execFile } from "child_process";
|
||||
import { createHmac } from "crypto";
|
||||
import got from "got";
|
||||
import got, { HTTPError } from "got";
|
||||
import { readdirSync } from "fs";
|
||||
|
||||
type Session = typeof sessionsTable.$inferSelect & {
|
||||
@@ -50,7 +50,13 @@ try {
|
||||
// - получать список приложений
|
||||
// - отправить список приложений на сервер
|
||||
|
||||
const serverInfo = await getServerInfo();
|
||||
let serverInfo;
|
||||
|
||||
try {
|
||||
serverInfo = await getServerInfo();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
async function getServerInfo() {
|
||||
try {
|
||||
@@ -76,20 +82,30 @@ async function addApps() {
|
||||
.update(JSON.stringify(json))
|
||||
.digest("base64");
|
||||
|
||||
await got.post(`${process.env.API_URL}/apps`, {
|
||||
headers: {
|
||||
Authorization: `Hmac ${signature}`,
|
||||
},
|
||||
json,
|
||||
});
|
||||
await got
|
||||
.post(`${process.env.API_URL}/apps`, {
|
||||
headers: {
|
||||
Authorization: `Hmac ${signature}`,
|
||||
},
|
||||
json,
|
||||
})
|
||||
.json();
|
||||
|
||||
console.log("Apps added");
|
||||
} catch (error) {
|
||||
console.error("Error sending installed apps:", error);
|
||||
// if (error instanceof HTTPError) {
|
||||
// console.error("Error sending installed apps:", error.response.body);
|
||||
// } else {
|
||||
// console.error((error as Error).message);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
await addApps();
|
||||
try {
|
||||
await addApps();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
async function getSessions() {
|
||||
const session = await db.query.sessionsTable.findFirst({
|
||||
|
||||
Reference in New Issue
Block a user