Edits history of script submission #15835 for ' Create App (fly)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Fly = {
      token: string;
    };
    /**
     * Create App
     * Create an app with the specified details in the request body.
    
     */
    export async function main(
      auth: Fly,
      body: {
        app_name?: string;
        enable_subdomains?: false | true;
        network?: string;
        org_slug?: string;
      },
    ) {
      const url = new URL(`https://api.machines.dev/v1/apps`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 235 days ago