@ariacompute/router-ts 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@ariacompute/router-ts",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "node --test test/binding.test.mjs"
8
+ }
9
+ }
package/src/index.js ADDED
@@ -0,0 +1,20 @@
1
+ export class Router {
2
+ constructor() {
3
+ this._auth = { base_url: "", token: "" };
4
+ }
5
+
6
+ setup(u = {}) {
7
+ if (u.base_url !== undefined) this._auth.base_url = u.base_url;
8
+ if (u.token !== undefined) this._auth.token = u.token;
9
+ return this;
10
+ }
11
+
12
+ setupStatus() {
13
+ return { ...this._auth };
14
+ }
15
+
16
+ setupClear() {
17
+ this._auth = { base_url: "", token: "" };
18
+ return this;
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { Router } from "../src/index.js";
4
+
5
+ test("setup memory only", () => {
6
+ const r = new Router();
7
+ r.setup({ base_url: "http://127.0.0.1:8899", token: "t" });
8
+ assert.equal(r.setupStatus().token, "t");
9
+ r.setupClear();
10
+ assert.equal(r.setupStatus().token, "");
11
+ });