Initial commit

This commit is contained in:
Paul Fey 2025-06-20 09:47:10 +02:00
commit c310cd7943
19 changed files with 3939 additions and 0 deletions

2
app-side/i18n/en-US.po Normal file
View file

@ -0,0 +1,2 @@
msgid "example"
msgstr "This is an example in app-side"

60
app-side/index.js Normal file
View file

@ -0,0 +1,60 @@
import { MessageBuilder } from "../shared/message-side";
const messageBuilder = new MessageBuilder();
async function fetchDirectory(ctx) {
try {
const res = await fetch({
url: "https://directory.spaceapi.io",
method: "GET",
});
const resBody =
typeof res.body === "string" ? JSON.parse(res.body) : res.body;
ctx.response({
data: { success: true, result: resBody },
});
} catch (error) {
ctx.response({
data: { success: false, result: {} },
});
}
}
async function fetchStatus(url, ctx) {
try {
const res = await fetch({
url: url,
method: "GET",
});
const resBody =
typeof res.body === "string" ? JSON.parse(res.body) : res.body;
ctx.response({
data: { success: true, result: resBody },
});
} catch (error) {
ctx.response({
data: { success: false, result: {} },
});
}
}
AppSideService({
onInit() {
messageBuilder.listen(() => {});
messageBuilder.on("request", (ctx) => {
const jsonRpc = messageBuilder.buf2Json(ctx.request.payload);
if (jsonRpc.method === "GET_DIRECTORY") {
return fetchDirectory(ctx);
} else if (jsonRpc.method === "GET_STATUS") {
return fetchStatus(jsonRpc.url, ctx);
}
});
},
onRun() {},
onDestroy() {},
});