Skip to content

Commit

Permalink
Merge pull request #8 from synadia-io/jsdoc
Browse files Browse the repository at this point in the history
added js doc and refactored some terms
  • Loading branch information
aricart authored Apr 23, 2024
2 parents f1711ea + 13c3a5e commit 6810b83
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 14 deletions.
2 changes: 1 addition & 1 deletion nhgc/jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@synadiaorbit/nhgc",
"version": "0.0.1",
"version": "0.0.2",
"exports": "./mod.ts"
}
10 changes: 5 additions & 5 deletions nhgc/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
Kv,
KvBucketInfo,
KvEntry,
KvOperation,
KvWatchFn,
KvWatchOpts,
Operation,
ReviverFn,
toKvChangeEvent,
Value,
Expand All @@ -33,7 +33,7 @@ type KvE = {
created: string;
revision: number;
delta: number;
operation: Operation;
operation: KvOperation;
value: Uint8Array;
};

Expand Down Expand Up @@ -65,7 +65,7 @@ class KvEntryImpl implements KvEntry {
created: r.headers.get("X-Nats-Kv-Created") || "",
revision: parseInt(r.headers.get("X-Nats-Kv-Revision") || "0"),
delta: parseInt(r.headers.get("X-Nats-Kv-Delta") || "0"),
operation: r.headers.get("X-Nats-Kv-Operation") as Operation,
operation: r.headers.get("X-Nats-Kv-Operation") as KvOperation,
value,
};
return Promise.resolve(new KvEntryImpl(kve));
Expand All @@ -76,7 +76,7 @@ class KvEntryImpl implements KvEntry {
return this.entry.value;
}

get operation(): Operation {
get operation(): KvOperation {
return this.entry.operation;
}

Expand Down Expand Up @@ -241,7 +241,7 @@ export class KvImpl extends HttpImpl implements Kv {
opts: KvWatchOpts,
): Promise<KvWatcher> {
const args: string[] = [];
args.push(`X-Nats-Api-Key=${this.apiKey}`);
args.push(`authorization=${this.apiKey}`);

const dopts = Object.assign({
filter: ">",
Expand Down
11 changes: 11 additions & 0 deletions nhgc/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@
import { Kvm } from "./types.ts";
import { KvmImpl } from "./kvm.ts";

/**
* Interface to the API of the NHG
*/
export interface NHG {
/**
* Return an object that you can use to manage or access
* KeyValue stores.
*/
kvm: Kvm;
}

/**
* Creates a client for the Nats-Http-Gateway.
* @param opts
*/
export function newNHG(
opts: { url: string; apiKey: string },
): NHG {
Expand Down
2 changes: 1 addition & 1 deletion nhgc/nhgc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class HttpImpl implements Http {
}
const r = Object.assign(opts, { method, body });
const headers = new Headers(opts.headers);
headers.append("X-Nats-Api-Key", this.apiKey);
headers.append("Authorization", this.apiKey);
r.headers = headers;
return fetch(u, r);
}
Expand Down
Loading

0 comments on commit 6810b83

Please sign in to comment.