Some checks failed
CI / test (push) Failing after 43s
- Introduced ESLint configuration files for both api and web packages to enforce coding standards. - Updated MinioService and TokenService to improve error handling and type definitions. - Refactored localStorage access in web components to use window.localStorage for consistency. - Enhanced ESLint rules in base configuration to improve code quality and maintainability.
19 lines
536 B
TypeScript
19 lines
536 B
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
import { MercuriusContext } from 'mercurius';
|
|
|
|
const isCallback = (
|
|
maybeFunction: unknown | Function
|
|
): maybeFunction is Function => typeof maybeFunction === 'function';
|
|
|
|
export const withAuth = <T>(callback: T) =>
|
|
async function (
|
|
_: unknown,
|
|
__: unknown,
|
|
context: MercuriusContext,
|
|
info: unknown
|
|
) {
|
|
if (!context.jwt) {
|
|
throw new Error('Not authenticated!');
|
|
}
|
|
return isCallback(callback) && callback(_, __, context, info);
|
|
};
|