MicroHack-Registrations-RestAPI / src / services / registration / registration.logs.ts
registration.logs.ts
Raw
import Logger from "../../utils/Logger";

export type IRegistrationLogs =
  | "GET_ALL_REGISTRATIONS_SUCCESS"
  | "GET_REGISTRATION_SUCCESS"
  | "REGISTER_SUCCESS"
  | "GET_ALL_REGISTRATIONS_ERROR"
  | "GET_REGISTRATION_ERROR"
  | "REGISTER_ERROR"
  | "REGISTRATION_NOT_FOUND"
  | "REGISTER_ERROR_EMAIL_EXIST"
  | "EXPORT_REGISTRATIONS_SUCCESS"
  | "EXPORT_REGISTRATIONS_ERROR"
  | "EXPORT_REGISTRATIONS_NOT_FOUND"
  ;

export const registrationLogs: IErrors<IRegistrationLogs> = {
  GET_ALL_REGISTRATIONS_SUCCESS: {
    code: 0,
    message: "All registrations {count} have been successfully retrieved.",
    type: "GET_ALL_REGISTRATIONS_SUCCESS",
  },
  GET_REGISTRATION_SUCCESS: {
    code: 1,
    message:
      "Registration details for ID {id} have been successfully retrieved.",
    type: "GET_REGISTRATION_SUCCESS",
  },
  REGISTER_SUCCESS: {
    code: 2,
    message: "Registration completed successfully.",
    type: "REGISTER_SUCCESS",
  },
  GET_ALL_REGISTRATIONS_ERROR: {
    code: 3,
    message: "Failed to retrieve all registrations due to: {error}",
    type: "GET_ALL_REGISTRATIONS_ERROR",
  },
  GET_REGISTRATION_ERROR: {
    code: 4,
    message:
      "Failed to retrieve registration with ID {id} due to: {error}",
    type: "GET_REGISTRATION_ERROR",
  },
  REGISTER_ERROR: {
    code: 5,
    message: "Failed to complete registration due to: {error}",
    type: "REGISTER_ERROR",
  },
  REGISTRATION_NOT_FOUND: {
    code: 6,
    message: "Registration with ID {id} does not exist.",
    type: "REGISTRATION_NOT_FOUND",
  },
  REGISTER_ERROR_EMAIL_EXIST: {
    code: 7,
    message: "Failed to register, {email} already registered.",
    type: "REGISTER_ERROR_EMAIL_EXIST",
  },
  EXPORT_REGISTRATIONS_SUCCESS: {
    code: 8,
    message: "All registrations have been successfully exported.",
    type: "EXPORT_REGISTRATIONS_SUCCESS",
  },
  EXPORT_REGISTRATIONS_ERROR: {
    code: 9,
    message: "Failed to export registrations due to: {error}",
    type: "EXPORT_REGISTRATIONS_ERROR",
  },
  EXPORT_REGISTRATIONS_NOT_FOUND: {
    code: 10,
    message: "No registrations found to export.",
    type: "EXPORT_REGISTRATIONS_NOT_FOUND",
  },
} as const;

export default registrationLogs;
export const registrationLogger = new Logger("registration");