Compare commits

..

No commits in common. "main" and "1.1.0" have entirely different histories.
main ... 1.1.0

10 changed files with 413 additions and 1042 deletions

3
.npmrc
View File

@ -1,3 +0,0 @@
@astrogd:registry=https://git.astrogd.cloud/api/packages/packages/npm/
@internal:registry=https://git.astrogd.cloud/api/packages/internal/npm/
//git.astrogd.cloud/api/packages/internal/npm/:_authToken=${NPM_TOKEN}

View File

@ -2,18 +2,7 @@
This file is used to list changes made to this software.
_Current development release: 1.1.1_
## V1.1.1 [2023-09-16]
### Updates
- Updated packages to latest versions
### Bugfixes
- Fixed a bug where the bot would crash on startup if the database connection establishment took too long
### Other
- Renamed db service in docker compose file from database to db
_Current development release: 1.1.0_
## V1.1.0 [2022-11-29]

View File

@ -8,16 +8,15 @@ services:
tty: true
stdin_open: true
depends_on:
- db
- database
restart: unless-stopped
environment:
- TOKEN=$TOKEN
- DB_HOST=db
- DB_HOST=database
- DB_USERNAME=$DB_USERNAME
- DB_PASSWORD=$DB_PASSWORD
- DB_DATABASE=$DB_DATABASE
- MONITOR_URL=$MONITOR_URL
db:
database:
image: postgres:latest
restart: unless-stopped
ports:

1354
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,22 @@
{
"name": "eu.astrogd.white-leopard",
"version": "1.2.0",
"version": "1.1.0",
"description": "A Discord bot that checks channel names for blacklisted words and reverts the changes if necessary",
"main": "build/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc && shx cp package-lock.json build/package-lock.json",
"start:rebuild": "npm run build && node --enable-source-maps .",
"version:dev": "npm version prerelease --preid dev --no-commit-hooks --no-git-tag-version",
"version:patch": "npm version prepatch --preid dev --no-commit-hooks --no-git-tag-version",
"version:minor": "npm version preminor --preid dev --no-commit-hooks --no-git-tag-version",
"version:major": "npm version premajor --preid dev --no-commit-hooks --no-git-tag-version",
"version:release": "npm version patch --no-commit-hooks --no-git-tag-version",
"deploy-commands:dev": "ts-node ci/devDeploy.ts",
"deploy-commands:prod": "ts-node ci/deploy.ts",
"deploy:dev": "npm run build && npm run deploy-commands:dev && docker compose build && docker compose up -d",
"deploy:prod": "rimraf build && npm run build && npm run deploy-commands:prod && docker build -t astrogd/white-leopard:latest . && docker push astrogd/white-leopard:latest",
"start": "npm run build && npm run deploy-commands:dev && docker-compose up -d db && node --enable-source-maps .",
"migration:create": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:generate -d src/data/dataSource.migration.ts -p src/data/migrations/data",
"migration:run": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:run -d src/data/dataSource.migration.ts",
"migration:revert": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:revert -d src/data/dataSource.migration.ts",
"migration:show": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:show -d src/data/dataSource.migration.ts",
"migration:check": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:generate --check -d src/data/dataSource.migration.ts src/data/migrations/data"
"start": "npm run build && npm run deploy-commands:dev && docker-compose up --no-start && docker compose start database && node --enable-source-maps .",
"migration:create": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:generate -d src/data/dataSource.ts -p src/data/migrations/data",
"migration:run": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:run -d src/data/dataSource.ts",
"migration:revert": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:revert -d src/data/dataSource.ts",
"migration:show": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:show -d src/data/dataSource.ts",
"migration:check": "node --require ts-node/register ./node_modules/typeorm/cli.js migration:generate --check -d src/data/dataSource.ts src/data/migrations/data"
},
"repository": {
"type": "git",
@ -35,16 +30,15 @@
"homepage": "https://github.com/r-Overwatch2/eu.astrogd.white-leopard#readme",
"devDependencies": {
"@types/express": "^4.17.14",
"@types/fs-extra": "^11.0.2",
"@types/node": "^18.17.17",
"rimraf": "^5.0.1",
"@types/fs-extra": "^9.0.13",
"@types/node": "^18.11.9",
"rimraf": "^3.0.2",
"shx": "^0.3.4",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
"typescript": "^4.9.3"
},
"dependencies": {
"@astrogd/eu.astrogd.uptime-kuma-push-monitor": "^1.0.0-dev.3",
"discord.js": "^14.13.0",
"discord.js": "^14.6.0",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"fs-extra": "^11.0.0",

View File

@ -1,25 +1,13 @@
import { runCleanup } from "../service";
import client from "./index";
import { initPromise } from "../data/dataSource";
import pushMonitor from "@astrogd/eu.astrogd.uptime-kuma-push-monitor";
const token = process.env["TOKEN"];
if (!token) throw new ReferenceError("TOKEN environment variable is missing");
async function run() {
console.log("Establishing database connection");
await initPromise;
console.log("Connection established\nAuthenticating with Discord API");
client.login(token);
}
client.login(token);
client.on("ready", async () => {
client.on("ready", () => {
console.log(`Connected to Discord API. Bot account is ${client.user?.tag} (${client.user?.id})`);
if (process.env["MONITOR_URL"]) pushMonitor.register(process.env["MONITOR_URL"], 120);
pushMonitor.enableShutdownNotifications();
pushMonitor.setPerformanceHandler(() => client.ws.ping);
runCleanup();
});
run();

View File

@ -1,3 +0,0 @@
import dataSource from "./dataSource";
export default dataSource;

View File

@ -28,9 +28,6 @@ const dataSource = new DataSource({
migrationsTransactionMode: "each"
});
const initPromise = dataSource.initialize();
dataSource.initialize();
export default dataSource;
export {
initPromise
}

View File

@ -1,3 +1,4 @@
import "./uptime";
import runCleanup from "./cleanup";
export {

19
src/service/uptime.ts Normal file
View File

@ -0,0 +1,19 @@
import express from "express";
import pack from "../../package.json";
import startupTime from "../tools/startupTime";
const app = express();
app.get("/", (_req, res) => {
res.status(200).json({
running: true,
version: pack.version,
runningSince: startupTime.toISOString()
});
});
app.all("*", (_req, res) => {
res.status(404).end();
});
app.listen(80);