Something went wrong. Try again.
Schedule posts and reposts to Bluesky (and other PDSes) with Cloudflare workers. skyscheduler.work
scheduling social-media cloudflare bsky service cloudflare-workers bsky-tool bluesky
Something went wrong. Try again.
1.2 kB · 36 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536import * as z from "zod/v4";import { MAX_ALT_TEXT } from "../limits";import { checkValidDateStr } from "../utils/time";import { AppPasswordDefinition, PasswordDefinition, UsernameDefinition } from "./sharedDefinitions";
export const UsernameSchema = z.object({ username: UsernameDefinition.clone() .nonempty("username is missing") .nonoptional()});
export const PasswordSchema = z.object({ password: PasswordDefinition.clone().nonoptional(),});
export const BSkyAppPasswordSchema = z.object({ bskyAppPassword: AppPasswordDefinition});
export const AltTextSchema = z.object({ alt: z.string().trim() .max(MAX_ALT_TEXT, "alt text is too long") .prefault("")});
export const ScheduledDateSchema = z.object({ // no matter what the client does end up sending, we floor to the nearest valid time. // // this value is fully verified in the superRefines for the post/repost schemas as there is additional // logic to check for scheduledDate: z.string().trim() .nonempty("scheduled date is malformed") .nonoptional("scheduled date must be provided") .refine((date) => checkValidDateStr(date), {error: "invalid date, please use ISO 8601 format", abort: true, path: ["scheduledDate"]}),});