Commit Graph

13 Commits

Author SHA1 Message Date
Yasuhiro Matsumoto
2771d9b8ba fix(all): use v2 module 2023-05-08 12:49:11 -03:00
Gustavo Chain
304831f749 move AfterSave method from relay to storage 2023-02-10 10:37:46 -03:00
0x0ff
9ba4326085 fix: pass unix timestamp to DB.Exec instead of Time 2022-12-29 13:57:49 -03:00
Saul Freeberty
05e8f03d43 move timestamp variable under condition 2022-12-26 19:53:00 -03:00
Saul Freeberty
8fd148bbb5 remove expired invoice, and fix display unexpired invoice 2022-12-26 19:53:00 -03:00
Saul Freeberty
bacf19b88d remove empty space 2022-12-25 20:54:49 -03:00
Saul Freeberty
3c953e4ae8 fix expensive relay invoice handler 2022-12-25 20:54:49 -03:00
alex
627724f702 start: introduce Server type and Shutdown (breaking change)
the main motivation for this change is to be able to run tests.
before this commit, Start, Router and Log operated on global variables,
making automated testing unreasonably hard.

this commit puts all that a server needs in a new Server type,
which also made it possible for a Server.Shutdown - see ShutdownAware
doc comments.

BREAKING CHANGES:
- Relay.OnInitialized takes one argument now, *relayer.Server.
- relayer.Router is now replaced by relayer.Server.Router().
  package users can still hook into the router from OnInitialized
  for custom HTTP routing.
- relayer.Log is gone. apart from another global var, imho this was
  a too opinionated choice for a framework to build a custom relay upon.
  this commit introduces a Logger interface which package users can implement
  for zerolog to make it log like before. see Server.Log for details.

other notable changes: finally added a couple basic tests, for start up
and shutdown. doc comments now explain most of the essentials,
hopefully making it more approachable for newcomers and easier to understand
the relayer package.

the changes in handlers.go are minimal, although git diff goes crazy.
this is because most of the lines are simply shifted indentation back by one
due to go fmt.

before this commit:

    func handleWebsocket(relay Relay) func(http.ResponseWriter, *http.Request)
    func handleNIP11(relay Relay) func(http.ResponseWriter, *http.Request)

after:

    func (s *Server) handleWebsocket(w http.ResponseWriter, r *http.Request)
    func (s *Server) handleNIP11(w http.ResponseWriter, r *http.Request)
2022-12-24 20:41:02 -03:00
alex
642710fda8 start: propagate init errors
package users can now act accordingly on startup errors, for example
by exiting with a non-zero code. this is useful when running a service,
notifying a supervising process about such failures.

although this is technically a breaking change, most pkg users should be
unaffected since Start and StartConf returned nothing before this commit.
2022-12-24 18:52:06 -03:00
fiatjaf
4b2fc819a1 fix expensive html bolt11 printing. 2022-12-15 21:35:40 -03:00
fiatjaf
d7aba0b21f fix some dependencies and storage instantiation on example relays. 2022-11-11 09:46:18 -03:00
fiatjaf
eee9952fac base58 bad-coding session. 2022-08-12 17:02:40 -03:00
fiatjaf
aa96fa0a21 refactor framework interface, simplify basic and whitelisted, bring expensive on and rewrite it. 2022-07-24 17:41:00 -03:00