All functions documented

This commit is contained in:
Javier Sanchez 2025-06-24 12:58:53 +00:00
parent 80b7374acf
commit b03ae03380
18 changed files with 1025 additions and 19 deletions

View File

@ -17,4 +17,4 @@ COPY src ./src
RUN chmod +x ./src/index.js
# Set entrypoint for npx-style usage
ENTRYPOINT ["node", "src/index.js"]
ENTRYPOINT ["node", "src/index.js"]

View File

@ -7,4 +7,4 @@ services:
- TOKEN=${TOKEN}
command: ["--host_url", "$HOST_URL", "--token", "$TOKEN"]
ports:
- "3000:3000"
- "3000:3000"

35
src/tools.js Normal file
View File

@ -0,0 +1,35 @@
const CoolifyClient = require('./coolifyClient');
async function health(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/health');
}
async function version(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/version');
}
async function listApps(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/applications');
}
async function startApp(host_url, token, id) {
const client = new CoolifyClient(host_url, token);
return client.post(`/api/v1/applications/${id}/start`, {});
}
async function stopApp(host_url, token, id) {
const client = new CoolifyClient(host_url, token);
return client.post(`/api/v1/applications/${id}/stop`, {});
}
module.exports = {
health,
version,
listApps,
startApp,
stopApp,
};

View File

@ -1,49 +1,370 @@
const CoolifyClient = require('../coolifyClient');
// List all applications
/**
* List all applications.
* @param {string} host_url - Coolify instance URL
* @param {string} token - Bearer token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/applications');
}
// Create new application (public repo)
/**
* Get application by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @returns {Promise<Object>}
* @example
* get('https://coolify.example.com', 'TOKEN', 'app-uuid');
*/
async function get(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/applications/${uuid}`);
}
/**
* Create new application (public repo).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Application creation payload.
* @param {string} data.project_uuid - The project UUID. (required)
* @param {string} data.server_uuid - The server UUID. (required)
* @param {string} data.environment_name - The environment name. (required, at least one of environment_name or environment_uuid)
* @param {string} data.environment_uuid - The environment UUID. (required, at least one of environment_name or environment_uuid)
* @param {string} data.git_repository - The git repository URL. (required)
* @param {string} data.git_branch - The git branch. (required)
* @param {string} data.build_pack - The build pack type. One of: 'nixpacks', 'static', 'dockerfile', 'dockercompose'. (required)
* @param {string} data.ports_exposes - The ports to expose. (required)
* @param {string} [data.destination_uuid] - The destination UUID.
* @param {string} [data.name] - The application name.
* @param {string} [data.description] - The application description.
* @param {string} [data.domains] - The application domains.
* @param {string} [data.git_commit_sha] - The git commit SHA.
* @param {string} [data.docker_registry_image_name] - The docker registry image name.
* @param {string} [data.docker_registry_image_tag] - The docker registry image tag.
* @param {boolean} [data.is_static] - The flag to indicate if the application is static.
* @param {string} [data.static_image] - The static image. Enum: ['nginx:alpine']
* @param {string} [data.install_command] - The install command.
* @param {string} [data.build_command] - The build command.
* @param {string} [data.start_command] - The start command.
* @param {string} [data.ports_mappings] - The ports mappings.
* @param {string} [data.base_directory] - The base directory for all commands.
* @param {string} [data.publish_directory] - The publish directory.
* @param {boolean} [data.health_check_enabled] - Health check enabled.
* @param {string} [data.health_check_path] - Health check path.
* @param {string} [data.health_check_port] - Health check port.
* @param {string} [data.health_check_host] - Health check host.
* @param {string} [data.health_check_method] - Health check method.
* @param {integer} [data.health_check_return_code] - Health check return code.
* @param {string} [data.health_check_scheme] - Health check scheme.
* @param {string} [data.health_check_response_text] - Health check response text.
* @param {integer} [data.health_check_interval] - Health check interval in seconds.
* @param {integer} [data.health_check_timeout] - Health check timeout in seconds.
* @param {integer} [data.health_check_retries] - Health check retries count.
* @param {integer} [data.health_check_start_period] - Health check start period in seconds.
* @param {string} [data.limits_memory] - Memory limit.
* @param {string} [data.limits_memory_swap] - Memory swap limit.
* @param {integer} [data.limits_memory_swappiness] - Memory swappiness.
* @param {string} [data.limits_memory_reservation] - Memory reservation.
* @param {string} [data.limits_cpus] - CPU limit.
* @param {string} [data.limits_cpuset] - CPU set.
* @param {integer} [data.limits_cpu_shares] - CPU shares.
* @param {string} [data.custom_labels] - Custom labels.
* @param {string} [data.custom_docker_run_options] - Custom docker run options.
* @param {string} [data.post_deployment_command] - Post deployment command.
* @param {string} [data.post_deployment_command_container] - Post deployment command container.
* @param {string} [data.pre_deployment_command] - Pre deployment command.
* @param {string} [data.pre_deployment_command_container] - Pre deployment command container.
* @param {string} [data.manual_webhook_secret_github] - Manual webhook secret for Github.
* @param {string} [data.manual_webhook_secret_gitlab] - Manual webhook secret for Gitlab.
* @param {string} [data.manual_webhook_secret_bitbucket] - Manual webhook secret for Bitbucket.
* @param {string} [data.manual_webhook_secret_gitea] - Manual webhook secret for Gitea.
* @param {string} [data.redirect] - How to set redirect with Traefik / Caddy. Enum: [www, non-www, both]
* @param {boolean} [data.instant_deploy] - The flag to indicate if the application should be deployed instantly.
* @param {string} [data.dockerfile] - The Dockerfile content.
* @param {string} [data.docker_compose_location] - The Docker Compose location.
* @param {string} [data.docker_compose_raw] - The Docker Compose raw content.
* @param {string} [data.docker_compose_custom_start_command] - The Docker Compose custom start command.
* @param {string} [data.docker_compose_custom_build_command] - The Docker Compose custom build command.
* @param {array} [data.docker_compose_domains] - The Docker Compose domains.
* @param {string} [data.watch_paths] - The watch paths.
* @param {boolean} [data.use_build_server] - Use build server.
* @returns {Promise<Object>}
* @example
* createPublic('https://coolify.example.com', 'TOKEN', {
* project_uuid: '123',
* server_uuid: '456',
* environment_name: 'production',
* environment_uuid: 'env-uuid',
* git_repository: 'https://github.com/user/repo.git',
* git_branch: 'main',
* build_pack: 'nixpacks',
* ports_exposes: '3000',
* name: 'My App',
* description: 'A sample app',
* // ...other optional fields
* });
*/
async function createPublic(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/applications/public', data);
}
// Create new application (private GitHub app)
/**
* Create new application (private GitHub app).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Application creation payload (see OpenAPI)
* @returns {Promise<Object>}
* @example
* createPrivateGithubApp('https://coolify.example.com', 'TOKEN', { ... });
*/
async function createPrivateGithubApp(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/applications/private-github-app', data);
}
// Create new application (private deploy key)
/**
* Create new application (private deploy key).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Application creation payload (see OpenAPI)
* @returns {Promise<Object>}
* @example
* createPrivateDeployKey('https://coolify.example.com', 'TOKEN', { ... });
*/
async function createPrivateDeployKey(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/applications/private-deploy-key', data);
}
// Dockerfile, Dockerimage, Dockercompose, etc.
async function dockerfile(host_url, token, data) {
/**
* Create new application (Dockerfile).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Application creation payload (see OpenAPI)
* @returns {Promise<Object>}
* @example
* createDockerfile('https://coolify.example.com', 'TOKEN', { ... });
*/
async function createDockerfile(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/applications/dockerfile', data);
}
async function dockerimage(host_url, token, data) {
/**
* Create new application (Docker image).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Application creation payload (see OpenAPI)
* @returns {Promise<Object>}
* @example
* createDockerimage('https://coolify.example.com', 'TOKEN', { ... });
*/
async function createDockerimage(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/applications/dockerimage', data);
}
async function dockercompose(host_url, token, data) {
/**
* Create new application (Docker Compose).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Application creation payload (see OpenAPI)
* @returns {Promise<Object>}
* @example
* createDockercompose('https://coolify.example.com', 'TOKEN', { ... });
*/
async function createDockercompose(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/applications/dockercompose', data);
}
/**
* Update application by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} data - Update payload
* @returns {Promise<Object>}
* @example
* update('https://coolify.example.com', 'TOKEN', 'app-uuid', { ... });
*/
async function update(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.patch(`/api/v1/applications/${uuid}`, data);
}
/**
* Delete application by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} params - Optional query params (delete_configurations, delete_volumes, etc.)
* @returns {Promise<Object>}
* @example
* remove('https://coolify.example.com', 'TOKEN', 'app-uuid', { delete_configurations: true });
*/
async function remove(host_url, token, uuid, params = {}) {
const client = new CoolifyClient(host_url, token);
return client.delete(`/api/v1/applications/${uuid}`, { params });
}
/**
* List all envs by application UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @returns {Promise<Object[]>}
* @example
* listEnvs('https://coolify.example.com', 'TOKEN', 'app-uuid');
*/
async function listEnvs(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/applications/${uuid}/envs`);
}
/**
* Create env by application UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} data - Env payload
* @returns {Promise<Object>}
* @example
* createEnv('https://coolify.example.com', 'TOKEN', 'app-uuid', { key: 'FOO', value: 'bar' });
*/
async function createEnv(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.post(`/api/v1/applications/${uuid}/envs`, data);
}
/**
* Update env by application UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} data - Env update payload
* @returns {Promise<Object>}
* @example
* updateEnv('https://coolify.example.com', 'TOKEN', 'app-uuid', { key: 'FOO', value: 'baz' });
*/
async function updateEnv(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.patch(`/api/v1/applications/${uuid}/envs`, data);
}
/**
* Update multiple envs by application UUID (bulk).
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} data - Bulk envs update payload
* @returns {Promise<Object>}
* @example
* updateEnvsBulk('https://coolify.example.com', 'TOKEN', 'app-uuid', { data: [...] });
*/
async function updateEnvsBulk(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.patch(`/api/v1/applications/${uuid}/envs/bulk`, data);
}
/**
* Delete env by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {string} env_uuid - Env UUID
* @returns {Promise<Object>}
* @example
* removeEnv('https://coolify.example.com', 'TOKEN', 'app-uuid', 'env-uuid');
*/
async function removeEnv(host_url, token, uuid, env_uuid) {
const client = new CoolifyClient(host_url, token);
return client.delete(`/api/v1/applications/${uuid}/envs/${env_uuid}`);
}
/**
* Start application by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} params - Optional query params (force, instant_deploy)
* @returns {Promise<Object>}
* @example
* start('https://coolify.example.com', 'TOKEN', 'app-uuid', { force: true });
*/
async function start(host_url, token, uuid, params = {}) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/applications/${uuid}/start`, { params });
}
/**
* Stop application by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @returns {Promise<Object>}
* @example
* stop('https://coolify.example.com', 'TOKEN', 'app-uuid');
*/
async function stop(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/applications/${uuid}/stop`);
}
/**
* Restart application by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @returns {Promise<Object>}
* @example
* restart('https://coolify.example.com', 'TOKEN', 'app-uuid');
*/
async function restart(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/applications/${uuid}/restart`);
}
/**
* Execute a command on the application's current container.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Application UUID
* @param {Object} data - { command: string }
* @returns {Promise<Object>}
* @example
* execute('https://coolify.example.com', 'TOKEN', 'app-uuid', { command: 'ls -la' });
*/
async function execute(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.post(`/api/v1/applications/${uuid}/execute`, data);
}
module.exports = {
list,
get,
createPublic,
createPrivateGithubApp,
createPrivateDeployKey,
dockerfile,
dockerimage,
dockercompose,
createDockerfile,
createDockerimage,
createDockercompose,
update,
remove,
listEnvs,
createEnv,
updateEnv,
updateEnvsBulk,
removeEnv,
start,
stop,
restart,
execute,
};

157
src/tools/databases.js Normal file
View File

@ -0,0 +1,157 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all databases.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/databases');
}
/**
* Get database by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Database UUID
* @returns {Promise<Object>}
* @example
* get('https://coolify.example.com', 'TOKEN', 'db-uuid');
*/
async function get(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/databases/${uuid}`);
}
/**
* Create a new PostgreSQL database.
* @param {string} host_url
* @param {string} token
* @param {Object} data - Database creation payload.
* @param {string} data.server_uuid - UUID of the server. (required)
* @param {string} data.project_uuid - UUID of the project. (required)
* @param {string} data.environment_name - Name of the environment. (required, at least one of environment_name or environment_uuid)
* @param {string} data.environment_uuid - UUID of the environment. (required, at least one of environment_name or environment_uuid)
* @param {string} [data.postgres_user] - PostgreSQL user.
* @param {string} [data.postgres_password] - PostgreSQL password.
* @param {string} [data.postgres_db] - PostgreSQL database.
* @param {string} [data.postgres_initdb_args] - PostgreSQL initdb args.
* @param {string} [data.postgres_host_auth_method] - PostgreSQL host auth method.
* @param {string} [data.postgres_conf] - PostgreSQL conf.
* @param {string} [data.destination_uuid] - UUID of the destination if the server has multiple destinations.
* @param {string} [data.name] - Name of the database.
* @param {string} [data.description] - Description of the database.
* @param {string} [data.image] - Docker Image of the database.
* @param {boolean} [data.is_public] - Is the database public?
* @param {integer} [data.public_port] - Public port of the database.
* @param {string} [data.limits_memory] - Memory limit of the database.
* @param {string} [data.limits_memory_swap] - Memory swap limit of the database.
* @param {integer} [data.limits_memory_swappiness] - Memory swappiness of the database.
* @param {string} [data.limits_memory_reservation] - Memory reservation of the database.
* @param {string} [data.limits_cpus] - CPU limit of the database.
* @param {string} [data.limits_cpuset] - CPU set of the database.
* @param {integer} [data.limits_cpu_shares] - CPU shares of the database.
* @param {boolean} [data.instant_deploy] - Instant deploy the database.
* @returns {Promise<Object>}
* @example
* createPostgreSQL('https://coolify.example.com', 'TOKEN', {
* server_uuid: 'server-uuid',
* project_uuid: 'project-uuid',
* environment_name: 'production',
* environment_uuid: 'env-uuid',
* postgres_user: 'user',
* postgres_password: 'pass',
* postgres_db: 'dbname',
* // ...other optional fields
* });
*/
async function createPostgreSQL(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/databases/postgresql', data);
}
/**
* Update database by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Database UUID
* @param {Object} data - Update payload
* @returns {Promise<Object>}
* @example
* update('https://coolify.example.com', 'TOKEN', 'db-uuid', { ... });
*/
async function update(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.patch(`/api/v1/databases/${uuid}`, data);
}
/**
* Delete database by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Database UUID
* @param {Object} params - Optional query params (delete_configurations, delete_volumes, etc.)
* @returns {Promise<Object>}
* @example
* remove('https://coolify.example.com', 'TOKEN', 'db-uuid', { delete_configurations: true });
*/
async function remove(host_url, token, uuid, params = {}) {
const client = new CoolifyClient(host_url, token);
return client.delete(`/api/v1/databases/${uuid}`, { params });
}
/**
* Start database by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Database UUID
* @returns {Promise<Object>}
* @example
* start('https://coolify.example.com', 'TOKEN', 'db-uuid');
*/
async function start(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/databases/${uuid}/start`);
}
/**
* Stop database by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Database UUID
* @returns {Promise<Object>}
* @example
* stop('https://coolify.example.com', 'TOKEN', 'db-uuid');
*/
async function stop(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/databases/${uuid}/stop`);
}
/**
* Restart database by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Database UUID
* @returns {Promise<Object>}
* @example
* restart('https://coolify.example.com', 'TOKEN', 'db-uuid');
*/
async function restart(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/databases/${uuid}/restart`);
}
module.exports = {
list,
get,
update,
remove,
start,
stop,
restart,
};

View File

@ -1,13 +1,16 @@
const CoolifyClient = require('../coolifyClient');
/**
* Despliega recursos según la configuración de Coolify.
* Deploy resources by tag or uuid (see OpenAPI for params).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Parámetros para el despliegue (ver OpenAPI para detalles).
* @param {Object} data - Parameters for deployment.
* @param {string} [data.tag] - Tag name(s). Comma separated list is also accepted.
* @param {string} [data.uuid] - Resource UUID(s). Comma separated list is also accepted.
* @param {boolean} [data.force] - Force rebuild (without cache).
* @returns {Promise<Object>}
* @example
* deploy('https://coolify.example.com', 'TOKEN', { id: 'uuid', ... });
* deploy('https://coolify.example.com', 'TOKEN', { tag: 'v1.0.0', force: true });
*/
async function deploy(host_url, token, data) {
const client = new CoolifyClient(host_url, token);

48
src/tools/deployments.js Normal file
View File

@ -0,0 +1,48 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all currently running deployments.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/deployments');
}
/**
* Get deployment by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Deployment UUID
* @returns {Promise<Object>}
* @example
* get('https://coolify.example.com', 'TOKEN', 'deployment-uuid');
*/
async function get(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/deployments/${uuid}`);
}
/**
* Deploy by tag or uuid.
* @param {string} host_url
* @param {string} token
* @param {Object} params - { tag, uuid, force }
* @returns {Promise<Object>}
* @example
* deploy('https://coolify.example.com', 'TOKEN', { tag: 'v1.0.0' });
*/
async function deploy(host_url, token, params = {}) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/deploy', { params });
}
module.exports = {
list,
get,
deploy,
};

View File

@ -1,13 +1,15 @@
const CoolifyClient = require('../coolifyClient');
/**
* Deshabilita un recurso (según OpenAPI, puede requerir ID o parámetros específicos).
* Disable a resource (see OpenAPI for required params).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Parámetros para deshabilitar el recurso (ver OpenAPI para detalles).
* @param {Object} data - Parameters for disabling the resource.
* @param {string} data.id - The UUID of the resource to disable. (required)
* @param {string} [data.type] - The type of resource (e.g., 'application', 'database', etc.).
* @returns {Promise<Object>}
* @example
* disable('https://coolify.example.com', 'TOKEN', { id: 'uuid', ... });
* disable('https://coolify.example.com', 'TOKEN', { id: 'uuid', type: 'application' });
*/
async function disable(host_url, token, data) {
const client = new CoolifyClient(host_url, token);

18
src/tools/domains.js Normal file
View File

@ -0,0 +1,18 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all domains.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/domains');
}
module.exports = {
list,
};

21
src/tools/enable.js Normal file
View File

@ -0,0 +1,21 @@
const CoolifyClient = require('../coolifyClient');
/**
* Enable a resource (see OpenAPI for required params).
* @param {string} host_url
* @param {string} token
* @param {Object} data - Parameters for enabling the resource.
* @param {string} data.id - The UUID of the resource to enable. (required)
* @param {string} [data.type] - The type of resource (e.g., 'application', 'database', etc.).
* @returns {Promise<Object>}
* @example
* enable('https://coolify.example.com', 'TOKEN', { id: 'uuid', type: 'application' });
*/
async function enable(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/enable', { params: data });
}
module.exports = {
enable,
};

18
src/tools/health.js Normal file
View File

@ -0,0 +1,18 @@
const CoolifyClient = require('../coolifyClient');
/**
* Get Coolify API health status.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object>}
* @example
* health('https://coolify.example.com', 'TOKEN');
*/
async function health(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/health');
}
module.exports = {
health,
};

18
src/tools/keys.js Normal file
View File

@ -0,0 +1,18 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all security keys.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/security/keys');
}
module.exports = {
list,
};

100
src/tools/projects.js Normal file
View File

@ -0,0 +1,100 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all projects.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/projects');
}
/**
* Get project by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Project UUID
* @returns {Promise<Object>}
* @example
* get('https://coolify.example.com', 'TOKEN', 'project-uuid');
*/
async function get(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/projects/${uuid}`);
}
/**
* Create a new project.
* @param {string} host_url
* @param {string} token
* @param {Object} data - Project creation payload.
* @param {string} data.name - The name of the project. (required)
* @param {string} [data.description] - The description of the project.
* @returns {Promise<Object>}
* @example
* create('https://coolify.example.com', 'TOKEN', {
* name: 'My Project',
* description: 'A sample project',
* });
*/
async function create(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/projects', data);
}
/**
* Update project by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Project UUID
* @param {Object} data - Update payload
* @returns {Promise<Object>}
* @example
* update('https://coolify.example.com', 'TOKEN', 'project-uuid', { ... });
*/
async function update(host_url, token, uuid, data) {
const client = new CoolifyClient(host_url, token);
return client.patch(`/api/v1/projects/${uuid}`, data);
}
/**
* Delete project by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Project UUID
* @returns {Promise<Object>}
* @example
* remove('https://coolify.example.com', 'TOKEN', 'project-uuid');
*/
async function remove(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.delete(`/api/v1/projects/${uuid}`);
}
/**
* Get project environment by name or UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Project UUID
* @param {string} environment - Environment name or UUID
* @returns {Promise<Object>}
* @example
* getEnvironment('https://coolify.example.com', 'TOKEN', 'project-uuid', 'production');
*/
async function getEnvironment(host_url, token, uuid, environment) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/projects/${uuid}/${environment}`);
}
module.exports = {
list,
get,
create,
update,
remove,
getEnvironment,
};

18
src/tools/resources.js Normal file
View File

@ -0,0 +1,18 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all resources.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/resources');
}
module.exports = {
list,
};

109
src/tools/servers.js Normal file
View File

@ -0,0 +1,109 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all servers.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/servers');
}
/**
* Get server by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Server UUID
* @returns {Promise<Object>}
* @example
* get('https://coolify.example.com', 'TOKEN', 'server-uuid');
*/
async function get(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/servers/${uuid}`);
}
/**
* Create a new server.
* @param {string} host_url
* @param {string} token
* @param {Object} data - Server creation payload.
* @param {string} data.name - The name of the server. (required)
* @param {string} [data.description] - The description of the server.
* @param {string} data.ip - The IP of the server. (required)
* @param {integer} data.port - The port of the server. (required)
* @param {string} data.user - The user of the server. (required)
* @param {string} data.private_key_uuid - The UUID of the private key. (required)
* @param {boolean} [data.is_build_server] - Is build server.
* @param {boolean} [data.instant_validate] - Instant validate.
* @param {string} [data.proxy_type] - The proxy type. Enum: ['traefik', 'caddy', 'none']
* @returns {Promise<Object>}
* @example
* create('https://coolify.example.com', 'TOKEN', {
* name: 'My Server',
* ip: '127.0.0.1',
* port: 22,
* user: 'root',
* private_key_uuid: 'key-uuid',
* proxy_type: 'traefik',
* });
*/
async function create(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/servers', data);
}
/**
* Get resources by server UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Server UUID
* @returns {Promise<Object[]>}
* @example
* getResources('https://coolify.example.com', 'TOKEN', 'server-uuid');
*/
async function getResources(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/servers/${uuid}/resources`);
}
/**
* Get domains by server UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Server UUID
* @returns {Promise<Object[]>}
* @example
* getDomains('https://coolify.example.com', 'TOKEN', 'server-uuid');
*/
async function getDomains(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/servers/${uuid}/domains`);
}
/**
* Validate server by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Server UUID
* @returns {Promise<Object>}
* @example
* validate('https://coolify.example.com', 'TOKEN', 'server-uuid');
*/
async function validate(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/servers/${uuid}/validate`);
}
module.exports = {
list,
get,
create,
getResources,
getDomains,
validate,
};

74
src/tools/services.js Normal file
View File

@ -0,0 +1,74 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all services.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/services');
}
/**
* Get service by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Service UUID
* @returns {Promise<Object>}
* @example
* get('https://coolify.example.com', 'TOKEN', 'service-uuid');
*/
async function get(host_url, token, uuid) {
const client = new CoolifyClient(host_url, token);
return client.get(`/api/v1/services/${uuid}`);
}
/**
* Create a new service.
* @param {string} host_url
* @param {string} token
* @param {Object} data - Service creation payload.
* @param {string} data.name - The name of the service. (required)
* @param {string} [data.description] - The description of the service.
* @param {string} data.server_uuid - The UUID of the server. (required)
* @param {string} data.project_uuid - The UUID of the project. (required)
* @param {string} [data.environment_name] - The environment name.
* @param {string} [data.environment_uuid] - The environment UUID.
* @returns {Promise<Object>}
* @example
* create('https://coolify.example.com', 'TOKEN', {
* name: 'My Service',
* server_uuid: 'server-uuid',
* project_uuid: 'project-uuid',
* environment_name: 'production',
* });
*/
async function create(host_url, token, data) {
const client = new CoolifyClient(host_url, token);
return client.post('/api/v1/services', data);
}
/**
* Delete service by UUID.
* @param {string} host_url
* @param {string} token
* @param {string} uuid - Service UUID
* @param {Object} params - Optional query params (delete_configurations, delete_volumes, etc.)
* @returns {Promise<Object>}
* @example
* remove('https://coolify.example.com', 'TOKEN', 'service-uuid', { delete_configurations: true });
*/
async function remove(host_url, token, uuid, params = {}) {
const client = new CoolifyClient(host_url, token);
return client.delete(`/api/v1/services/${uuid}`, { params });
}
module.exports = {
list,
get,
remove,
};

46
src/tools/teams.js Normal file
View File

@ -0,0 +1,46 @@
const CoolifyClient = require('../coolifyClient');
/**
* List all teams.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* list('https://coolify.example.com', 'TOKEN');
*/
async function list(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/teams');
}
/**
* Get current team.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object>}
* @example
* current('https://coolify.example.com', 'TOKEN');
*/
async function current(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/teams/current');
}
/**
* List current team members.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object[]>}
* @example
* currentMembers('https://coolify.example.com', 'TOKEN');
*/
async function currentMembers(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/teams/current/members');
}
module.exports = {
list,
current,
currentMembers,
};

18
src/tools/version.js Normal file
View File

@ -0,0 +1,18 @@
const CoolifyClient = require('../coolifyClient');
/**
* Get Coolify version.
* @param {string} host_url
* @param {string} token
* @returns {Promise<Object>}
* @example
* version('https://coolify.example.com', 'TOKEN');
*/
async function version(host_url, token) {
const client = new CoolifyClient(host_url, token);
return client.get('/api/v1/version');
}
module.exports = {
version,
};