MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / connectWithUnixSockets

Function connectWithUnixSockets

run/idp-sql/cloud-sql.js:43–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 * @returns {object} Knex's PostgreSQL client
42 */
43const connectWithUnixSockets = async credConfig => {
44 const dbSocketPath = process.env.DB_SOCKET_PATH || '/cloudsql';
45 // Establish a connection to the database
46 return Knex({
47 client: 'pg',
48 connection: {
49 user: credConfig.DB_USER, // e.g. 'my-user'
50 password: credConfig.DB_PASSWORD, // e.g. 'my-user-password'
51 database: credConfig.DB_NAME, // e.g. 'my-database'
52 host: `${dbSocketPath}/${credConfig.CLOUD_SQL_CONNECTION_NAME}`,
53 },
54 ...config,
55 });
56};
57// [END cloudrun_user_auth_sql_connect]
58
59// Method to connect locally on Windows

Callers 1

connectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected