uncleJim21 / cascdr-vendor

Streamlined NIP105 server for Paid Lightning (L402) API services. Can run inside of StartOS box in conjunction with LND or CLN (future dev)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Data Buffets

Hi welcome to Data Buffets!

  1. Download Bun
curl -fsSL https://bun.sh/install | bash
  1. Clone this repo
git clone https://github.com/Team-Pleb-TabConf-2023/Monorepo
cd Monorepo
  1. Copy .env.example and fill out the required fields ( For now the Chat GPT API )
cp .env.example .env
  1. Install Dependancies
bun install
  1. Run Server
bun cascdr-vendor
  1. Run ChatGPT script in a new terminal
bun cascdr-vendor-test

Adding a Service

Create a new file in apps/server/services directory and implement and export a NIP105Service:

/** Defines the interface for a service.
 * Each service should be it's own file in the `services/` directory
 * */
export interface NIP105Service {
  /** The service being provided */
  service: string;
  /** Creates the service note to be posted */
  createServiceEvent: (serverEndpoint: string) => Promise<NostrEvent> | NostrEvent;
  /** Optional: Defines the retries for the service */
  getTries?: (requestBody: any) => Promise<number> | number;
  /** Returns the price of the service given the request body */
  getPrice: (requestBody: any) => Promise<number> | number;
  /** Validates the request, should throw a detailed error on failure */
  validate: (requestBody: any) => Promise<void> | void;
  /** Processes the specific request, should return a status 500 | 202 | 200 */
  process: (requestBody: any) => Promise<[number, any]> | [number, any]; //status, response
}

Then in apps/server/index.ts import and add the service to the SERVICES array.

// ------------------- SERVICE SETUP -------------------
import { chatGPT } from "./services/chatGPT";

const SERVICES: NIP105Service[] = [
  chatGPT,
  // Enter Services Here
];

About

Streamlined NIP105 server for Paid Lightning (L402) API services. Can run inside of StartOS box in conjunction with LND or CLN (future dev)

License:MIT License


Languages

Language:TypeScript 98.8%Language:CSS 1.2%