Class reference
Curl

Url Reference

Types

UrlOpts

The options for configuring a CURL request.

NameTypeRequiredDescription
deststringYesThe destination path to save the downloaded file
urlstringYesThe URL to download
silentbooleanYesWhether to print the command output
chdirstringNoThe directory to change to before executing the command
timeoutnumberNoThe timeout duration in seconds

UrlSafeGetResponse

The response object returned by CURL requests.

NameTypeDescription
successbooleanWhether the request was successful
errorShellCommandError | nullThe error that occurred (if any)

Url Class

The Url class provides methods for making CURL requests.

Constructor

The Url class constructor accepts a UrlOpts object.

import { Url, UrlOpts } from "@vaibhavvenkat/aacod";
 
const opts: UrlOpts = {
    dest: "/path/to/save",
    url: "https://example.com/file.txt",
    silent: false,
    chdir: "/path/to/directory",
    timeout: 30,
};
 
const url = new Url(opts);

Methods

safeGet(): Promise<UrlSafeGetResponse>

Safely performs CURL without throwing an error.

const res: UrlSafeGetResponse = await url.safeGet();
get(): Promise<void>

Performs CURL on the given url.

await url.get();