mirror of
https://github.com/edufeed-org/eventstore.git
synced 2025-12-07 23:34:32 +00:00
Add a little bit of README and use correct repo link
This commit is contained in:
parent
faf3be92f4
commit
4bf16247bc
2 changed files with 59 additions and 1 deletions
58
README.md
Normal file
58
README.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Eventstore
|
||||
|
||||
Eventstore to be used with [khatru](https://github.com/fiatjaf/khatru) relays.
|
||||
|
||||
Current available stores:
|
||||
- typesense30142: A relay specialiced for [AMB](https://dini-ag-kim.github.io/amb/latest/#context) Metadata events. See https://github.com/edufeed-org/nips/blob/edufeed-amb/edufeed.md for the current AMB NIP
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/fiatjaf/khatru"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/sroertgen/eventstore/typesense30142"
|
||||
)
|
||||
|
||||
func main() {
|
||||
relay := khatru.NewRelay()
|
||||
relay.Info.Name = "A edufeed relay for AMB metadata"
|
||||
relay.Info.PubKey = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
|
||||
relay.Info.Description = "this is the typesense custom relay"
|
||||
relay.Info.Icon = "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fliquipedia.net%2Fcommons%2Fimages%2F3%2F35%2FSCProbe.jpg&f=1&nofb=1&ipt=0cbbfef25bce41da63d910e86c3c343e6c3b9d63194ca9755351bb7c2efa3359&ipo=images"
|
||||
db := typesense30142.TSBackend{
|
||||
ApiKey: "xyz",
|
||||
Host: "http://localhost:8108",
|
||||
CollectionName: "amb",
|
||||
}
|
||||
if err := db.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
relay.OnConnect = append(relay.OnConnect, func(ctx context.Context) {
|
||||
khatru.RequestAuth(ctx)
|
||||
})
|
||||
|
||||
relay.QueryEvents = append(relay.QueryEvents, db.QueryEvents)
|
||||
relay.DeleteEvent = append(relay.DeleteEvent, db.DeleteEvent)
|
||||
relay.ReplaceEvent = append(relay.ReplaceEvent, db.ReplaceEvent)
|
||||
relay.Negentropy = true
|
||||
|
||||
relay.RejectEvent = append(relay.RejectEvent,
|
||||
func(ctx context.Context, event *nostr.Event) (reject bool, msg string) {
|
||||
if event.Kind != 30142 {
|
||||
return true, "we don't allow these kinds here. It's a 30142 only place."
|
||||
}
|
||||
return false, ""
|
||||
},
|
||||
)
|
||||
|
||||
fmt.Println("running on :3334")
|
||||
http.ListenAndServe(":3334", relay)
|
||||
}
|
||||
|
||||
```
|
||||
2
go.mod
2
go.mod
|
|
@ -1,4 +1,4 @@
|
|||
module github.com/sroertgen/eventstore
|
||||
module github.com/edufeed-org/eventstore
|
||||
|
||||
go 1.24.1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue