or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Database Connection with Keep-Alive

A Node.js module that creates a PostgreSQL database connection with TCP keep-alive configuration to maintain connectivity over long periods.

Capabilities

Creates client with keep-alive configuration

  • Creates a client with TCP keep-alive enabled and initial delay set to 45000 milliseconds @test
  • The client successfully connects to a database at localhost:5432 with user 'testuser', password 'testpass', and database 'testdb' @test

Executes queries over persistent connection

  • Executes a SELECT query "SELECT 1 as value" and returns result with rows array containing one object with value property equal to 1 @test

Implementation

@generates

API

/**
 * Creates and returns a PostgreSQL client configured with TCP keep-alive.
 *
 * @param {Object} config - Database connection configuration
 * @param {string} config.host - Database host
 * @param {number} config.port - Database port
 * @param {string} config.user - Database user
 * @param {string} config.password - Database password
 * @param {string} config.database - Database name
 * @param {number} config.keepAliveInitialDelayMillis - TCP keep-alive initial delay in milliseconds
 * @returns {Object} Configured PostgreSQL client instance
 */
function createClient(config) {
  // IMPLEMENTATION HERE
}

module.exports = {
  createClient
};

Dependencies { .dependencies }

pg { .dependency }

Provides PostgreSQL database connectivity with TCP keep-alive support.