1package main
2
3import (
4	"github.com/writefreely/go-nodeinfo"
5	"net/http"
6)
7
8func main() {
9	cfg := nodeinfo.Config{
10		BaseURL: "http://localhost:8080",
11		InfoURL: "/api/nodeinfo",
12
13		Metadata: nodeinfo.Metadata{
14			NodeName:        "Agora",
15			NodeDescription: "A federated something-something.",
16			Private:         false,
17			MaxBlogs:        3,
18		},
19		Protocols: []nodeinfo.NodeProtocol{
20			nodeinfo.ProtocolActivityPub,
21		},
22		Services: nodeinfo.Services{
23			Inbound: []nodeinfo.NodeService{},
24			Outbound: []nodeinfo.NodeService{
25				nodeinfo.ServiceTwitter,
26				nodeinfo.ServiceTumblr,
27			},
28		},
29		Software: nodeinfo.SoftwareInfo{
30			Name:    "Agora",
31			Version: "1.0",
32		},
33	}
34	ni := nodeinfo.NewService(cfg, nodeInfoResolver{})
35
36	http.Handle(nodeinfo.NodeInfoPath, http.HandlerFunc(ni.NodeInfoDiscover))
37	http.Handle(cfg.InfoURL, http.HandlerFunc(ni.NodeInfo))
38
39	http.ListenAndServe(":8080", nil)
40}
41
42type nodeInfoResolver struct{}
43
44func (r nodeInfoResolver) IsOpenRegistration() (bool, error) {
45	return true, nil
46}
47
48func (r nodeInfoResolver) Usage() (nodeinfo.Usage, error) {
49	u := nodeinfo.Usage{
50		Users: nodeinfo.UsageUsers{
51			Total: 1,
52		},
53		LocalPosts: 1,
54	}
55	return u, nil
56}
57