chore: add backend-y bits of heartbeats

This commit is contained in:
41666 2021-03-12 20:45:35 -05:00
parent f65779f925
commit a34aebabe3
12 changed files with 174 additions and 2 deletions

View file

@ -69,6 +69,20 @@ export const getSessionID = (request: Request): { type: string; id: string } | n
return { type, id };
};
export const getSharedKey = (request: Request): { type: string; id: string } | null => {
const sharedKey = request.headers.get('authorization');
if (!sharedKey) {
return null;
}
const [type, id] = sharedKey.split(' ');
if (type !== 'Shared') {
return null;
}
return { type, id };
};
export const userAgent =
'DiscordBot (https://github.com/roleypoly/roleypoly, git-main) (+https://roleypoly.com)';

View file

@ -8,6 +8,7 @@ const list = (x: string) => x.split(',');
export const botClientID = env('BOT_CLIENT_ID');
export const botClientSecret = env('BOT_CLIENT_SECRET');
export const botToken = env('BOT_TOKEN');
export const botHeartbeatToken = env('BOT_HEARTBEAT_TOKEN');
export const uiPublicURI = safeURI(env('UI_PUBLIC_URI'));
export const apiPublicURI = safeURI(env('API_PUBLIC_URI'));
export const rootUsers = list(env('ROOT_USERS'));

View file

@ -88,3 +88,6 @@ const self = (global as any) as Record<string, any>;
export const Sessions = new WrappedKVNamespace(kvOrLocal(self.KV_SESSIONS ?? null));
export const GuildData = new WrappedKVNamespace(kvOrLocal(self.KV_GUILD_DATA ?? null));
export const Guilds = new WrappedKVNamespace(kvOrLocal(self.KV_GUILDS ?? null));
export const Infrastructure = new WrappedKVNamespace(
kvOrLocal(self.KV_INFRASTRUCTURE ?? null)
);