blob: b290fb951cfb398ae7eeba5fe93e29a605eeb043 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import getRates from "$lib/rates";
import { auth, fd, post } from "$lib/utils";
import { error, redirect } from "@sveltejs/kit";
export async function load({ parent }) {
const rates = await getRates();
const { user } = await parent();
return { rate: rates[user.currency] };
}
export const actions = {
default: async ({ cookies, request }) => {
let id;
const body = await fd(request);
try {
({ id } = await post("/mint", body, auth(cookies)));
} catch (e) {
const { message } = e as Error;
console.log("problem creating ecash", e);
error(400, { message });
}
redirect(307, `/ecash/${id}`);
},
};
|