5 Commits
2.0.3 ... 2.0.5

Author SHA1 Message Date
Fran Jurmanović
5aa69588fb add bot endpoints 2024-03-02 14:49:57 +01:00
Fran Jurmanović
28b028d056 increase version 2023-11-01 15:48:41 +01:00
Fran Jurmanović
4ac04d4457 formatting 2023-11-01 15:48:15 +01:00
Fran Jurmanović
9d137b6b52 fix legica date format 2023-11-01 15:46:04 +01:00
Fran Jurmanović
79110bdb1c version increase 2023-10-21 11:51:25 +02:00
3 changed files with 85 additions and 35 deletions

View File

@@ -1,35 +1,35 @@
{
"name": "legica-dana",
"version": "2.0.3",
"main": "src/app.ts",
"scripts": {
"start": "bun src/app.ts"
},
"author": "Fran Jurmanović <fjurma12@outlook.com>",
"license": "MIT",
"dependencies": {
"@elysiajs/cron": "^0.7.0",
"@elysiajs/static": "^0.7.1",
"@elysiajs/swagger": "^0.7.3",
"axios": "^0.26.0",
"body-parser": "^1.20.2",
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.11.10",
"discord.js": "^12.5.1",
"dotenv": "^8.2.0",
"elysia": "^0.7.15",
"lodash-es": "^4.17.21",
"minimatch": "^9.0.3",
"pino": "^8.15.4",
"typescript": "^4.1.5"
},
"devDependencies": {
"@types/lodash-es": "^4.17.9",
"@types/node": "^20.8.2",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"bun-types": "^1.0.4-canary.20231004T140131",
"eslint": "^8.50.0",
"prettier": "^2.2.1"
}
"name": "legica-dana",
"version": "2.0.5",
"main": "src/app.ts",
"scripts": {
"start": "bun src/app.ts"
},
"author": "Fran Jurmanović <fjurma12@outlook.com>",
"license": "MIT",
"dependencies": {
"@elysiajs/cron": "^0.7.0",
"@elysiajs/static": "^0.7.1",
"@elysiajs/swagger": "^0.7.3",
"axios": "^0.26.0",
"body-parser": "^1.20.2",
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.11.10",
"discord.js": "^12.5.1",
"dotenv": "^8.2.0",
"elysia": "^0.7.15",
"lodash-es": "^4.17.21",
"minimatch": "^9.0.3",
"pino": "^8.15.4",
"typescript": "^4.1.5"
},
"devDependencies": {
"@types/lodash-es": "^4.17.9",
"@types/node": "^20.8.2",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"bun-types": "^1.0.4-canary.20231004T140131",
"eslint": "^8.50.0",
"prettier": "^2.2.1"
}
}

View File

@@ -29,6 +29,55 @@ async function jobRunner() {
logger.error(err);
}
}
const botPlugin = new Elysia({ prefix: "/bot" })
.use(
basicAuth({
users: [
{
username: "admin",
password: config.PASSWORD,
},
],
errorMessage: "Unauthorized",
})
)
.get(
"/",
() => ({
uptime: client.uptime,
readyAt: client.readyAt,
readyTimestamp: client.readyTimestamp,
}),
{
detail: {
summary: "Get BOT status",
},
}
)
.post(
"/",
() => {
client.login(config.TOKEN);
return "Bot logged in started";
},
{
detail: {
summary: "Start BOT if it is not running",
},
}
)
.delete(
"/",
() => {
client.destroy();
return "Bot logged out";
},
{
detail: {
summary: "Stops the BOT.",
},
}
);
const taskPlugin = new Elysia({ prefix: "/job" })
.use(
@@ -138,7 +187,7 @@ const taskPlugin = new Elysia({ prefix: "/job" })
"/send",
async ({ set, body }) => {
try {
const url = body.url;
const url = body?.url;
if (url) {
await sendDiscordMessage(client, url);
} else {
@@ -212,6 +261,7 @@ const app = new Elysia()
)
.use(staticPlugin())
.use(taskPlugin)
.use(botPlugin)
.listen(config.PORT);
client.login(config.TOKEN);

View File

@@ -17,7 +17,7 @@ const config: ProjectConfig = {
APP_VERSION: version,
LEGICA_URL: "https://sib.net.hr/legica-dana",
TIMEZONE: process.env.TIMEZONE || "utc",
LEGICA_DATE_FORMAT: process.env.LEGICA_DATE_FORMAT || "DD.MM.YYYY",
LEGICA_DATE_FORMAT: process.env.LEGICA_DATE_FORMAT || "D.M.YYYY",
};
export { config };