#web-server #nostr #axum #nip98

nostr-web

utilities for building web servers for nostr

1 unstable release

0.1.0 Oct 30, 2023

#61 in #nostr

CC0 license

13KB
269 lines

nostr-web

Utilities for building web servers for nostr

Available utils

NIP-98 - HTTP Auth

There are extractors for actix and axum to provide a handler with the XOnlyPublicKey of the event in the auth header. If the event doesn't pass the checks defined in NIP-98, then a 401 will be returned as a response instead. An example handler for axum might look like this:

use nostr_web::nip98::Nip98PubKey;

async fn handler(Nip98PubKey(pubkey): Nip98PubKey) -> impl IntoResponse {
    StatusCode::OK
}

Installation

cargo add nostr-web

By default this will enable the parts of the code specific for axum. However, if you'd like to use actix-web instead, use the actix feature instead.

cargo add nostr-web --no-default-features

Dependencies

~16–28MB
~411K SLoC