web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

lib.ts (787B)


      1 import { KIND_PROFILE, type RadrootsProfile, type RadrootsProfileType } from "@radroots/events-bindings";
      2 import type { NostrEventFigure, NostrSignedEvent } from "../../types/nostr.js";
      3 import { nostr_event_create } from "../lib.js";
      4 import { tags_profile_type } from "./tags.js";
      5 
      6 export const nostr_event_profile = async (
      7     opts: NostrEventFigure<{ data: RadrootsProfile; profile_type?: RadrootsProfileType }>,
      8 ): Promise<NostrSignedEvent | undefined> => {
      9     const { data, profile_type, ...event_opts } = opts;
     10     const tags = tags_profile_type(profile_type);
     11     return nostr_event_create({
     12         ...event_opts,
     13         basis: {
     14             kind: KIND_PROFILE,
     15             content: JSON.stringify(data),
     16             tags: tags.length ? tags : undefined,
     17         },
     18     });
     19 };