All files / server/src/features/user userUtils.ts

100% Statements 7/7
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                        39x       120x 3x     3x   117x     39x     17x    
import { Dayjs } from "dayjs";
import { logger } from "server/utils/logger";
import { saveSerials } from "server/features/serial/serialRepository";
import { Result } from "shared/utils/result";
import { MongoDbError } from "shared/types/api/errors";
import { Serial } from "server/types/serialTypes";
 
interface HasSignupEndedParams {
  signupEndTime: Dayjs;
  timeNow: Dayjs;
}
 
export const hasSignupEnded = ({
  signupEndTime,
  timeNow,
}: HasSignupEndedParams): boolean => {
  if (timeNow.isAfter(signupEndTime)) {
    logger.warn(
      `Invalid signup time: timeNow: ${timeNow.toISOString()}, signupEndTime: ${signupEndTime.toISOString()}`,
    );
    return true;
  }
  return false;
};
 
export const createSerial = async (): Promise<
  Result<Serial[], MongoDbError>
> => {
  return await saveSerials(1);
};