aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/send/ecash/+page.server.ts
blob: d65c0046f39c34e9a2f45b87ef7b7104f57b1645 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { auth, fd, post } from "$lib/utils";
import { error, redirect } from "@sveltejs/kit";

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}`);
	},
};