const RegisterPayloadSchema = Schema.Struct({
username: Schema.String,
email: Schema.String,
password: Schema.String,
});
export type RegisterPayload = Schema.Schema.Type<typeof RegisterPayloadSchema>;
export const parseRegisterPayload = Schema.decodeUnknown(RegisterPayloadSchema);
const register = (payload: RegisterPayload) => {
const validated_payload = parseRegisterPayload(payload).pipe(
Effect.tap((res) => Effect.log("validated payload :", res)),
)
const hashed_password = Effect.runPromise(
pipe(
validated_payload.password,
hash_password,
Effect.tap((res) => Effect.log(`hashed_password : ${res}`)),
Effect.catchAll(() => {
new Response("hashing error", { status: 500 })
return Effect.fail("Send http response with hashing error")
})
)
)
//TODO: implement register
};
const RegisterPayloadSchema = Schema.Struct({
username: Schema.String,
email: Schema.String,
password: Schema.String,
});
export type RegisterPayload = Schema.Schema.Type<typeof RegisterPayloadSchema>;
export const parseRegisterPayload = Schema.decodeUnknown(RegisterPayloadSchema);
const register = (payload: RegisterPayload) => {
const validated_payload = parseRegisterPayload(payload).pipe(
Effect.tap((res) => Effect.log("validated payload :", res)),
)
const hashed_password = Effect.runPromise(
pipe(
validated_payload.password,
hash_password,
Effect.tap((res) => Effect.log(`hashed_password : ${res}`)),
Effect.catchAll(() => {
new Response("hashing error", { status: 500 })
return Effect.fail("Send http response with hashing error")
})
)
)
//TODO: implement register
};