refactor: api routes
This commit is contained in:
@@ -14,6 +14,7 @@ import { config } from "./config";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import type { BetterFetchResponse } from "@better-fetch/fetch";
|
||||
import { AuthSchema } from "@money/shared/auth";
|
||||
import { encode } from "node:punycode";
|
||||
|
||||
class AuthClientUnknownError extends Data.TaggedError(
|
||||
"AuthClientUnknownError",
|
||||
@@ -161,9 +162,10 @@ const requestAuth = Effect.gen(function* () {
|
||||
if (sessionData == null) return yield* Effect.fail(new AuthClientNoData());
|
||||
|
||||
const result = yield* Schema.decodeUnknown(AuthSchema)(sessionData);
|
||||
const encoded = yield* Schema.encode(AuthSchema)(result);
|
||||
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
yield* fs.writeFileString(config.authPath, JSON.stringify(result));
|
||||
yield* fs.writeFileString(config.authPath, JSON.stringify(encoded));
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user