0.8.3 • Published 1 year ago

@lawallet/module v0.8.3

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
1 year ago

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();
0.8.1

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.5.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.3.1

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago