0.0.5 • Published 5 months ago

@okjodom/fm-server v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
5 months ago

@fedimint/server

Fedimint SDK optimized for Node.js/Bun server environments.

Installation

npm install @fedimint/server
# or
yarn add @fedimint/server
# or
pnpm add @fedimint/server

Features

  • Optimized for server-side JavaScript environments (Node.js and Bun)
  • Pluggable storage adapters (LevelDB, File-based)
  • Server-specific utilities and helpers
  • Support for both ESM and CommonJS imports

Example Usage

// ESM
import { FedimintWallet } from '@fedimint/server'
import { LevelDBStorage } from '@fedimint/server/storage'

// CommonJS
const { FedimintWallet } = require('@fedimint/server')
const { LevelDBStorage } = require('@fedimint/server/storage')

// Initialize with Node.js optimized settings
const wallet = new FedimintWallet({
  storageAdapter: new LevelDBStorage('./data'),
  logLevel: 'info',
})

// Use the API the same way as in browser
await wallet.initialize()
await wallet.open('my-fedimint-client')

// Make module calls
const balance = await wallet.balance.getBalance()
console.log('Balance:', balance)

// Use Lightning module
const invoice = await wallet.lightning.createInvoice(1000, 'Test payment')
console.log('Invoice:', invoice)

Storage Adapters

LevelDB Storage

import { LevelDBStorage } from '@fedimint/server/storage'

const storage = new LevelDBStorage('./data', {
  createIfMissing: true,
})

const wallet = new FedimintWallet({
  storageAdapter: storage,
})

File Storage

import { FileStorage } from '@fedimint/server/storage'

const storage = new FileStorage('./data')

const wallet = new FedimintWallet({
  storageAdapter: storage,
})

Custom Storage Adapters

You can implement your own storage adapter by implementing the StorageAdapter interface:

import { StorageAdapter, Transaction } from '@fedimint/server/storage'

class MyCustomStorage implements StorageAdapter {
  // Implementation
}

License

MIT

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago