aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/printer/+page.server.ts
blob: e3fd9f8146831609ecd0f42c91e261d898cfdd4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { PUBLIC_COINOS_URL } from "$env/static/public";
import { fd } from "$lib/utils";
import { hex } from "@scure/base";

export const actions = {
  default: async ({ fetch, request }) => {
    const body = await fd(request);
    const res = await fetch(`${PUBLIC_COINOS_URL}/printer`, {
      method: "POST",
      body: JSON.stringify(body),
      headers: {
        "content-type": "application/json",
        accept: "application/octet-stream",
      },
    });

    return { data: hex.encode(new Uint8Array(await res.arrayBuffer())) };
  },
};