UNPKG

@mondaycom/apps-cli

Version:

A cli tool to manage apps (and monday-code projects) in monday.com

28 lines (27 loc) 1.12 kB
import { appStorageConnectionStringUrl } from '../consts/urls.js'; import { execute } from './api-service.js'; import { databaseConnectionStringResponseSchema } from './schemas/database-service-schemas.js'; import { HttpError } from '../types/errors/index.js'; import { HttpMethodTypes } from '../types/services/api-service.js'; import logger from '../utils/logger.js'; import { appsUrlBuilder } from '../utils/urls-builder.js'; export const getDatabaseConnectionString = async (appId) => { const DEBUG_TAG = 'get_database_connection_string'; try { const baseUrl = appStorageConnectionStringUrl(appId); const url = appsUrlBuilder(baseUrl); const response = await execute({ url, headers: { Accept: 'application/json' }, method: HttpMethodTypes.GET, }, databaseConnectionStringResponseSchema); return response; } catch (error) { logger.debug(error, DEBUG_TAG); if (error instanceof HttpError) { throw error; } throw new Error('Failed to fetch database connection string.'); } };