/** the purpose is to be able to explicitly manage database connection state and fail fast if our assumptions are wrong. the ManagedDatabaseConnection creates a managedConnection which must be explicitly `.start` ed before it can be used. - this normalizes the .end() connection requirement and makes the connection managment process much more explicit */ import { Connection, Pool } from 'mysql2/promise'; export default class ManagedDatabaseConnection { protected connectionOrPool: Connection | Pool | null; protected createConnectionOrPool: () => Promise; constructor({ createConnectionOrPool }: { createConnectionOrPool: () => Promise; }); start(): Promise; end(): Promise; execute(sql: string, values?: any): Promise; }