.ts
TypeScript
(application/typescript)
import { FastifyRequest } from "fastify";
import {
  ServiceApiContract,
  ServiceDependencies,
} from "@ethicdevs/react-monolith";

export interface AuthServiceAPI extends ServiceApiContract {
  compareUserPasswordHashes(a: string, b: string): boolean;
  isExistingUsername(username: string): boolean;
  isExistingUserUid(userUid: string): boolean;
  findUserByUsername(username: string): void;
  findUserByUid(userUid: string): void;
  sendUserEmailAddressV8nEmail(args: unknown[]): void;
  validateUserEmailAddress(
    userUid: string,
    emailAddress: string
  ): Promise<void>;
}

export interface AuthServiceDeps extends ServiceDependencies {
  // i.e. to access request decorators, one may pass request as a dependency
  //      to this service and all the methods within it would have access to
  //      a reference to it (i.e; database, cache, another service, etc...)
  request: FastifyRequest;
}