mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-24 22:58:15 +01:00
29 lines
761 B
TypeScript
29 lines
761 B
TypeScript
|
import { requestLimiter } from 'server/helpers/rateLimiter';
|
||
|
import { ContextType } from 'server/types/apiTypes';
|
||
|
import { toWithError } from 'server/helpers/async';
|
||
|
import { appUrls } from 'server/utils/appUrls';
|
||
|
import { logger } from 'server/helpers/logger';
|
||
|
|
||
|
export const githubResolvers = {
|
||
|
Query: {
|
||
|
getLatestVersion: async (
|
||
|
_: undefined,
|
||
|
params: any,
|
||
|
context: ContextType
|
||
|
) => {
|
||
|
await requestLimiter(context.ip, 'getLnPay');
|
||
|
|
||
|
const [response, error] = await toWithError(fetch(appUrls.github));
|
||
|
|
||
|
if (error) {
|
||
|
logger.debug('Unable to get latest github version');
|
||
|
throw new Error('NoGithubVersion');
|
||
|
}
|
||
|
|
||
|
const json = await response.json();
|
||
|
|
||
|
return json.tag_name;
|
||
|
},
|
||
|
},
|
||
|
};
|