aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/pos/+page.server.ts
blob: f7a3fda32ab851633f71106a16189fa2589ee80c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
		console.log("POSTING", body);
		const res = await fetch(`${PUBLIC_COINOS_URL}/flash`, {
			method: "POST",
			body: JSON.stringify(body),
			headers: {
				"content-type": "application/json",
				accept: "application/octet-stream",
			},
		});

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