All files / shared types.ts

80% Statements 4/5
66.66% Branches 2/3
66.66% Functions 2/3
80% Lines 4/5

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 32 33 34 35 36 37 3812x           781x               2x               12x                              
const PROTECTED_API_HTTP_METHODS = ['POST', 'PUT', 'DELETE', 'PATCH', 'GET'] as const
 
export type ProtectedApiHttpMethod = (typeof PROTECTED_API_HTTP_METHODS)[number]
 
export function isProtectedApiHttpMethod(method: string): method is ProtectedApiHttpMethod {
  // @ts-expect-error - We need to check if the method is a protected API HTTP method
  return PROTECTED_API_HTTP_METHODS.includes(method)
}
 
/**
 * @param method the HTTP method as a string
 * @returns true if the method is "simple" method, as defined by the CORS spec
 */
export function isSimpleMethod(method: string) {
  return method === 'GET' || method === 'POST' || method === 'HEAD'
}
 
export type ProtectedApi = {
  method: ProtectedApiHttpMethod
  url: string
}
 
const LOG_LEVELS = ['debug', 'info', 'warn', 'error'] as const
 
export type LogLevel = (typeof LOG_LEVELS)[number]
 
export function isLogLevel(level: string): level is LogLevel {
  // @ts-expect-error - We need to check if the level is valid
  return LOG_LEVELS.includes(level)
}
 
export interface Logger {
  debug: typeof console.debug
  info: typeof console.info
  warn: typeof console.warn
  error: typeof console.error
}