handy online tools for AT Protocol boat.kelinci.net
atproto bluesky atcute typescript solidjs
20
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: search param stuff

Mary b687cc5f 50ab940e

+16
+16
src/lib/utils/search-params.ts
··· 3 3 import { At } from '@atcute/client/lexicons'; 4 4 5 5 import { DID_OR_HANDLE_RE, DID_RE, HANDLE_RE } from '~/api/utils/strings'; 6 + import { UnwrapArray } from '~/api/utils/types'; 6 7 7 8 export interface ParamParser<T> { 8 9 parse: (value: string | string[] | null) => T | null; ··· 172 173 return value; 173 174 }, 174 175 }); 176 + 177 + export const asStringUnion = <const T extends [string, ...string[]][]>(values: T) => { 178 + return createParser({ 179 + parse(value) { 180 + if (typeof value === 'string' && values.includes(value as UnwrapArray<T>)) { 181 + return value; 182 + } 183 + 184 + return null; 185 + }, 186 + serialize(value) { 187 + return value; 188 + }, 189 + }); 190 + }; 175 191 176 192 export const asInteger = createParser({ 177 193 parse(value) {