@link-foundation/links-client
v1.0.0
Published
Node.js client library for link-cli (Links Theory database)
Maintainers
Readme
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 clinkPackage Installation
npm install @link-foundation/links-clientOr use GitHub directly:
npm install git+https://github.com/link-foundation/links-client.gitUsage
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: "[email protected]"
});
// 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 testsmenu-storage.js- Menu storage demonstrationauth-storage.js- Authentication storage demonstrationintegration.js- Full integration example
Testing
Run tests with Node.js test runner:
npm testLicense
The Unlicense
Links
- Repository: https://github.com/link-foundation/links-client
- link-cli: https://github.com/link-foundation/link-cli
