The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | export const Link = Schema.Struct({ |
| 4 | code: Schema.String, |
| 5 | url: Schema.String, |
| 6 | createdAt: Schema.String, |
| 7 | }); |
| 8 | export type Link = typeof Link.Type; |
| 9 | |
| 10 | /** A missing link: a typed error in code and a typed 404 over HTTP. */ |
| 11 | export class LinkNotFound extends Schema.TaggedError<LinkNotFound>()( |
| 12 | "LinkNotFound", |
| 13 | { code: Schema.String }, |
| 14 | { httpApiStatus: 404 }, |
| 15 | ) {} |
| 16 | |
| 17 | /** Short, URL-safe codes. */ |
| 18 | export const newCode = () => |
| 19 | Array.from(crypto.getRandomValues(new Uint8Array(6)), (b) => |
| 20 | "abcdefghijkmnpqrstuvwxyz23456789".charAt(b % 32), |
| 21 | ).join(""); |