0.1.6Updated a month ago
const [ TOKEN ] = Deno.env.get('DENO_AUTH_TOKENS')?.split('@') ?? '';

export class Viapak {
  static async get(path: string) {
    const route = `https://viapak.xyz/@viamedia/infinity-beyond@0.1.6${path.replace(/\/\./g, '/___.')}`;
    return await fetch(route, {
      headers: {
        Authorization: `Bearer ${TOKEN}`
      }
    });
  }

  static async text(path: string) {
    return (await this.get(path)).text();
  }

  static async blob(path: string) {
    return (await this.get(path)).blob();
  }

  static async json(path: string) {
    return (await this.get(path)).json();
  }

  static async body(path: string) {
    return (await this.get(path)).body;
  }

  private constructor() {}
}