All files / src index.ts

100% Statements 14/14
100% Branches 1/1
100% Functions 7/7
100% Lines 11/11

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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132                  4x 6x 5x     4x 7x 6x     6x                                                                                                                                                     4x 1x                                                         4x 1x            
/**
 * Entry point for the AWS Lambda boilerplate baseline.
 * Replace or extend these exports as Lambda-specific modules are introduced.
 *
 * @module index
 * @author Bayu Dwiyan Satria
 * @since 1.0.0
 */
 
export {
  helloHandler,
  resolveHelloInput
} from './handlers/hello'
 
export {
  directHelloHandler,
  resolveDirectHelloInput
} from './handlers/direct-hello'
 
export { scheduledHandler } from './handlers/scheduled'
 
export type {
  HelloRequestInput,
  HelloResponseBody
} from './handlers/hello'
 
export type {
  DirectHelloEvent,
  DirectHelloInput,
  DirectHelloResponse
} from './handlers/direct-hello'
 
export type { ScheduledRunResult } from './handlers/scheduled'
 
/**
 * @interface LibraryMetadata
 *
 * Metadata object describing the library or service.
 * Used to provide information about the module for consumers and documentation.
 *
 * @property {string} name - The name of the library or service
 * @property {string} version - The semantic version of the library
 * @property {string} [description] - Optional description of the library or service
 *
 * @author Bayu Dwiyan Satria
 * @since 1.0.0
 * @see {@link createLibraryMetadata}
 */
export interface LibraryMetadata {
  name: string
  version: string
  description?: string
}
 
/**
 * @interface HealthStatus
 *
 * Health check response indicating the operational state of the system.
 * Useful for smoke tests, readiness checks, and service health monitoring.
 *
 * @property {boolean} ok - Health status indicator; true when system is operational
 * @property {string} message - Human-readable health status message
 * @property {string} timestamp - ISO 8601 timestamp of when the health check was performed
 *
 * @author Bayu Dwiyan Satria
 * @since 1.0.0
 * @see {@link getHealthStatus}
 */
export interface HealthStatus {
  ok: boolean
  message: string
  timestamp: string
}
 
/**
 * @function getHealthStatus
 *
 * Returns a deterministic health payload useful for smoke tests and service availability checks.
 * The response includes a status indicator, message, and ISO 8601 timestamp.
 *
 * @param {string} [message='library-ready'] - Custom health status message
 * @returns {HealthStatus} Health status payload with ok=true, provided message, and current timestamp
 *
 * @example
 * const health = getHealthStatus();
 * // { ok: true, message: 'library-ready', timestamp: '2026-05-12T...' }
 *
 * @example
 * const customHealth = getHealthStatus('all-systems-nominal');
 * // { ok: true, message: 'all-systems-nominal', timestamp: '2026-05-12T...' }
 *
 * @author Bayu Dwiyan Satria
 * @since 1.0.0
 */
export const getHealthStatus = (message = 'library-ready'): HealthStatus => {
  return {
    ok: true,
    message,
    timestamp: new Date().toISOString()
  }
}
 
/**
 * @function createLibraryMetadata
 *
 * Creates a metadata object for consumers and documentation examples.
 * Encapsulates library name, version, and optional description for
 * introspection and logging purposes.
 *
 * @param {string} name - The name of the library or service
 * @param {string} version - The semantic version (e.g., '1.0.0', '2.1.3')
 * @param {string} [description] - Optional description of the library or service
 * @returns {LibraryMetadata} Metadata object containing name, version, and optional description
 *
 * @example
 * const metadata = createLibraryMetadata(
 *   'my-lambda-service',
 *   '1.0.0',
 *   'AWS Lambda boilerplate for serverless applications'
 * );
 *
 * @author Bayu Dwiyan Satria
 * @since 1.0.0
 */
export const createLibraryMetadata = (name: string, version: string, description?: string): LibraryMetadata => {
  return {
    name,
    version,
    description
  }
}