thunderhub/server/schema/github/resolvers.ts
Anthony Potdevin bc4415cde7
chore: 🔧 enable strict tsconfig (#96)
* chore: 🔧 strict enable wip

* Improve typings, add type dependencies (#97)

We improve the TypeScript situation by enabling `noImplicitAny`. This
leads to a bunch of errors, as expected. We fix some of these by
installing the correct types, and some are fixed manually by an educated
guess. There are still a lot left, and these seem to be a big mix of
lacking types for the `ln-service` dependency and potential bugs.

* Strict null (#100)

* chore: 🔧 enable strict-null

* chore: 🔧 more checks

* chore: 🔧 some fixes

* chore: 🔧 more types

* chore: 🔧 more types

* chore: 🔧 more types

* chore: 🔧 more types

* chore: 🔧 more types

* chore: 🔧 more types

* chore: 🔧 more types

* chore: 🔧 enable strict

* fix: 🐛 input

* fix: 🐛 forward report

* fix: 🐛 chat sending

* fix: 🐛 chat bubble input

Co-authored-by: Torkel Rogstad <torkel@rogstad.io>
2020-08-05 08:35:26 +02:00

28 lines
774 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 || !response) {
logger.debug('Unable to get latest github version');
throw new Error('NoGithubVersion');
}
const json = await response.json();
return json.tag_name;
},
},
};