mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
api/api-keys: log message to confirm successful file load
This commit is contained in:
parent
5ea23bee13
commit
af50852815
1 changed files with 8 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { env } from "../config.js";
|
import { env } from "../config.js";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readFile } from "node:fs/promises";
|
||||||
import { Yellow } from "../misc/console-text.js";
|
import { Green, Yellow } from "../misc/console-text.js";
|
||||||
import ip from "ipaddr.js";
|
import ip from "ipaddr.js";
|
||||||
|
|
||||||
// this function is a modified variation of code
|
// this function is a modified variation of code
|
||||||
|
@ -134,9 +134,13 @@ const loadKeys = async (source) => {
|
||||||
keys = formatKeys(updated);
|
keys = formatKeys(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapLoad = (url) => {
|
const wrapLoad = (url, initial = false) => {
|
||||||
loadKeys(url)
|
loadKeys(url)
|
||||||
.then(() => {})
|
.then(() => {
|
||||||
|
if (initial) {
|
||||||
|
console.log(`${Green('[✓]')} api keys loaded successfully!`)
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(`${Yellow('[!]')} Failed loading API keys at ${new Date().toISOString()}.`);
|
console.error(`${Yellow('[!]')} Failed loading API keys at ${new Date().toISOString()}.`);
|
||||||
console.error('Error:', e);
|
console.error('Error:', e);
|
||||||
|
@ -200,7 +204,7 @@ export const validateAuthorization = (req) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setup = (url) => {
|
export const setup = (url) => {
|
||||||
wrapLoad(url);
|
wrapLoad(url, true);
|
||||||
if (env.keyReloadInterval > 0) {
|
if (env.keyReloadInterval > 0) {
|
||||||
setInterval(() => wrapLoad(url), env.keyReloadInterval * 1000);
|
setInterval(() => wrapLoad(url), env.keyReloadInterval * 1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue