grain.social is a photo sharing platform built on atproto.
at main 1.3 kB view raw
1import { BffContext, RouteHandler } from "@bigmoves/bff"; 2import { UploadPage } from "../components/UploadPage.tsx"; 3import { getActorPhotos } from "../lib/actor.ts"; 4import { getGallery, getGalleryPhotos } from "../lib/gallery.ts"; 5import { getPageMeta } from "../meta.ts"; 6import type { State } from "../state.ts"; 7import { galleryLink } from "../utils.ts"; 8 9export const handler: RouteHandler = ( 10 req, 11 _params, 12 ctx: BffContext<State>, 13) => { 14 const { did, handle } = ctx.requireAuth(); 15 const url = new URL(req.url); 16 const selectedGalleryRkey = url.searchParams.get("gallery") ?? ""; 17 const selectedGalleryUri = 18 `at://${did}/social.grain.gallery/${selectedGalleryRkey}`; 19 const galleryRkey = url.searchParams.get("returnTo"); 20 const photos = selectedGalleryRkey 21 ? getGalleryPhotos(selectedGalleryUri, ctx) 22 : getActorPhotos(did, ctx); 23 const selectedGallery = getGallery(did, selectedGalleryRkey, ctx); 24 ctx.state.meta = [{ title: "Upload — Grain" }, ...getPageMeta("/upload")]; 25 return ctx.render( 26 <UploadPage 27 userDid={did} 28 userHandle={handle} 29 photos={photos} 30 returnTo={galleryRkey ? galleryLink(handle, galleryRkey) : undefined} 31 selectedGallery={selectedGallery ?? undefined} 32 />, 33 ); 34};