Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@lawallet/module

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lawallet/module

LaWallet Module

Source
npmnpm
Version
0.8.0
Version published
Weekly downloads
7
-84.44%
Maintainers
5
Weekly downloads
 
Created
Source

La Wallet Module

This is a library intended to ease the quick development of backend modules that interact with other backend.modules in the architecture described in lawallet.io

Installation

pnpm add @lawallet/module

Usage

The simplest usage is to declare the routes where the nostr listeners and rest routes will be and start the module:

import { Module } from '@lawallet/module';

const module = Module.build({
  nostrPath: `${import.meta.dirname}/nostr`,
  restPath: `${import.meta.dirname}/rest`,
});

module.start();

You can also provide anything you want to the context that will be available for nostr and rest handlers by extending the DefaultContext type. The following example adds a prisma client.

import {
  Module,
  DefaultContext,
  getWriteNDK,
  OutboxService,
} from '@lawallet/module';
import { PrismaClient } from '@prisma/client';

type Context = DefaultContext & { prisma: PrismaClient };

const context: Context = {
  outbox: new OutboxService(getWriteNDK()),
  prisma: new PrismaClient(),
};

const module = Module.build<Context>({
  context,
  nostrPath: `${import.meta.dirname}/nostr`,
  restPath: `${import.meta.dirname}/rest`,
});

module.start();

FAQs

Package last updated on 04 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts