Skip to content

Latest commit

 

History

History
116 lines (79 loc) · 2.19 KB

File metadata and controls

116 lines (79 loc) · 2.19 KB

Links Client - JavaScript/Node.js Implementation

Node.js client library for link-cli — implementation of Links Theory database.

Installation

Prerequisites

Install link-cli globally:

dotnet tool install --global clink

Package Installation

npm install @link-foundation/links-client

Or use GitHub directly:

npm install git+https://github.com/link-foundation/links-client.git

Usage

Basic Usage

import { LinkDBService } from '@link-foundation/links-client';

const db = new LinkDBService('/path/to/database.links');

// Create a link
const link = await db.createLink(100, 200);
console.log(link); // { id: 1, source: 100, target: 200 }

// Read all links
const links = await db.readAllLinks();

// Delete a link
await db.deleteLink(1);

Menu Storage

import { MenuStorageService } from '@link-foundation/links-client';

const menuStorage = new MenuStorageService();

const menu = [
  {
    label: "Dashboard",
    icon: "pi pi-home",
    to: "/dashboard",
    items: [
      { label: "Analytics", to: "/dashboard/analytics" }
    ]
  }
];

await menuStorage.storeMenuStructure(menu, 0);
const retrievedMenu = await menuStorage.getMenuStructure(0);

Authentication Storage

import { AuthStorageService } from '@link-foundation/links-client';

const authStorage = new AuthStorageService();

// Create user
const user = await authStorage.createUser({
  username: "alice",
  email: "alice@example.com"
});

// Set password
await authStorage.setPassword(user.userId, {
  hash: "hashed_password",
  salt: "random_salt"
});

API

For detailed API documentation, see the docs/ directory.

Examples

See examples in the examples/ directory:

  • basic-usage.js - Basic clink integration tests
  • menu-storage.js - Menu storage demonstration
  • auth-storage.js - Authentication storage demonstration
  • integration.js - Full integration example

Testing

Run tests with Node.js test runner:

npm test

License

The Unlicense

Links