Lasa is a stateless proxy that generates a RSS or an Atom feed from a Standard.site publication. lasa.anhgelus.world
rss atom atprotocol standard-site atproto
2
fork

Configure Feed

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

feat(cli): lasa usage

+106 -5
+1
.gitignore
··· 27 27 # End of https://www.toptal.com/developers/gitignore/api/go 28 28 29 29 testdata 30 + build
+2
README.md
··· 30 30 ``` 31 31 32 32 `build/lasad` is the daemon running the web server. 33 + 34 + `build/lasa` is a CLI.
+60
cmd/lasa/main.go
··· 1 + package main 2 + 3 + import ( 4 + "flag" 5 + ) 6 + 7 + var ( 8 + help bool 9 + ) 10 + 11 + func init() { 12 + flag.BoolVar(&help, "h", false, "show the help") 13 + } 14 + 15 + func main() { 16 + flag.Parse() 17 + args := flag.Args() 18 + if len(args) == 0 || help { 19 + handleHelp() 20 + return 21 + } 22 + command := args[0] 23 + var next []string 24 + if len(args) > 1 { 25 + next = args[1:] 26 + } 27 + switch command { 28 + case "help": 29 + handleHelp() 30 + case "publication": 31 + handlePublication(next) 32 + } 33 + } 34 + 35 + func handleHelp() { 36 + usage( 37 + `lasa <command>`, 38 + `Lasa is a CLI tool.`, 39 + []string{ 40 + "lasa publication\t-\tworks with publication", 41 + }, 42 + nil, 43 + )() 44 + } 45 + 46 + func handlePublication(args []string) { 47 + if len(args) == 0 { 48 + usage( 49 + `lasa publication <identifier> [rkey]`, 50 + `List publications of identifier (can be a DID or an Handle) or display a specific publication referenced by its rkey`, 51 + []string{ 52 + "lasa publication anhgelus.world\t-\tdisplay publications of anhgelus.world", 53 + "lasa publication did:plc:123\t-\tdisplay publications of did:plc:123", 54 + "lasa publication did:web:example.org fooBar\t-\tdisplay publication of did:web:example.org referenced by fooBar", 55 + }, 56 + nil, 57 + )() 58 + return 59 + } 60 + }
+32
cmd/lasa/print.go
··· 1 + package main 2 + 3 + import ( 4 + "flag" 5 + "fmt" 6 + "os" 7 + "text/tabwriter" 8 + ) 9 + 10 + func usage(syntax, usage string, examples []string, flags *flag.FlagSet) func() { 11 + return func() { 12 + fmt.Println("Usage:", syntax) 13 + fmt.Println(usage) 14 + w := tabwriter.NewWriter(os.Stdout, 0, 2, 1, ' ', 0) 15 + if flags != nil { 16 + fmt.Fprintln(w) 17 + fmt.Fprintln(w, "Options:") 18 + flags.VisitAll(func(f *flag.Flag) { 19 + fmt.Fprintln(w, "\t-", f.Name, "\t", f.Usage, "\t(default:", f.DefValue, ")") 20 + }) 21 + } 22 + fmt.Fprintln(w) 23 + fmt.Fprintln(w, "Examples:") 24 + for _, s := range examples { 25 + fmt.Fprintln(w, "\t", s) 26 + } 27 + err := w.Flush() 28 + if err != nil { 29 + panic(err) 30 + } 31 + } 32 + }
+7 -5
directory.go
··· 17 17 limiter *limitManyRequests[*atproto.DIDDocument] 18 18 } 19 19 20 - func NewDirectory(dir atproto.Directory, cache valkey.Client) *Directory { 20 + func NewDirectory(dir atproto.Directory, cache valkey.Client, dur time.Duration) *Directory { 21 21 return &Directory{ 22 - inner: dir, 23 - cache: cache, 22 + inner: dir, 23 + cache: cache, 24 + limiter: newLimitManyRequests[*atproto.DIDDocument](), 25 + duration: dur, 24 26 } 25 27 } 26 28 ··· 68 70 if doc != nil { 69 71 return doc, nil 70 72 } 71 - slog.Debug("cannot get DIDDocument from cache") 73 + slog.Debug("cannot get DIDDocument from cache, requesting") 72 74 73 75 return d.limiter.Do(key, func() (*atproto.DIDDocument, error) { 74 76 doc, err := d.inner.ResolveHandle(ctx, h) ··· 86 88 if doc != nil { 87 89 return doc, nil 88 90 } 89 - slog.Debug("cannot get DIDDocument from cache") 91 + slog.Debug("cannot get DIDDocument from cache, requesting") 90 92 91 93 return d.limiter.Do(key, func() (*atproto.DIDDocument, error) { 92 94 doc, err := d.inner.ResolveDID(ctx, did)
+4
justfile
··· 1 + build: build-lasa 2 + 3 + build-lasa: 4 + go build -ldflags "-s -w" -o build/lasa ./cmd/lasa/