Add the URL_POSTGRESQL environment variable

Mainly for flexibility purposes
Additionally to not expose credentials so plainly
This commit is contained in:
Taevas 2025-03-22 13:50:49 +01:00
parent d76c9be59d
commit 7a1d1e3276
4 changed files with 15 additions and 18 deletions

View file

@ -24,6 +24,7 @@ Set the environment variable IBM_TELEMETRY_DISABLED to true
This website makes use of several online APIs in order to deliver the `Infos` that are available on the right side of the main page. Accessing most of these APIs requires a key (or similar), which can be set through the following environment variables (with dotenv support for development):
- `URL_POSTGRESQL`
- `API_GITHUB`
- `API_GITLAB`
- `API_KITSUCLUB`

BIN
bun.lockb

Binary file not shown.

View file

@ -1,9 +1,7 @@
import { SQL } from "bun";
import type { Token } from "./api/token";
export const db = new SQL({
username: "postgres"
});
export const db = new SQL({url: process.env["URL_POSTGRESQL"]});
export const createTables = async (database: SQL): Promise<void> => {
return await database.begin(sql => sql`
@ -22,10 +20,8 @@ export const removeExpiredTokens = async (database: SQL): Promise<number> => {
WHERE expires <= ${Number(now)}
RETURNING *
`);
if (deleted_tokens.length) {
console.log("Removed", deleted_tokens.length, "token(s) that had expired!");
}
deleted_tokens.forEach(token => console.log("(DATABASE)", token.service, "token had expired on", new Date(Number(token.expires)), "and has been removed!"));
return deleted_tokens.length;
};
@ -42,7 +38,7 @@ export const addToken = async (database: SQL, token: {access_token: string, serv
RETURNING *
`);
console.log("Added new token for", token.service);
returned.forEach(token => console.log("(DATABASE)", token.service, "token has been added"));
return returned[0];
};

View file

@ -7,34 +7,34 @@
"start": "bun getready && bun run index.ts"
},
"dependencies": {
"@bachmacintosh/wanikani-api-types": "^1.7.0",
"@carbon/icons-react": "^11.56.0",
"@bachmacintosh/wanikani-api-types": "^1.8.0",
"@carbon/icons-react": "^11.57.0",
"@gitbeaker/rest": "^42.1.0",
"@octokit/rest": "^20.1.2",
"osu-api-v2-js": "^1.1.1",
"osu-api-v2-js": "^1.1.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"timeago.js": "^4.0.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.23.0",
"@stylistic/eslint-plugin": "^3.1.0",
"@tailwindcss/forms": "^0.5.10",
"@tailwindcss/postcss": "^4.0.13",
"@tailwindcss/postcss": "^4.0.15",
"@types/bun": "latest",
"@types/react": "^19.0.10",
"@types/react": "^19.0.12",
"@types/react-dom": "^19.0.4",
"dotenv": "^16.4.7",
"eslint": "^9.22.0",
"eslint": "^9.23.0",
"eslint-config-xo-typescript": "^7.0.0",
"eslint-plugin-react": "^7.37.4",
"postcss": "^8.5.3",
"react-animate-height": "^3.2.3",
"tailwindcss": "^4.0.13",
"tailwindcss": "^4.0.15",
"typescript": "^5.8.2",
"typescript-eslint": "^8.26.1",
"vite": "^6.2.1"
"typescript-eslint": "^8.27.0",
"vite": "^6.2.2"
},
"imports": {
"#Main/*": "./src/Main/*",