Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added js doc and refactored some terms #8

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading