- Add test/integration.test.ts: getServicePublicKey, full flow (register, login, createCollection, createPointFeature, listFeatures) - Update docs example: registerBySigningServiceKey then loginWithSignature - Document integration tests in typescript-frontend-integration.md Made-with: Cursor
This commit is contained in:
@@ -25,10 +25,12 @@ Deployment: API is proxied via reverse proxy from `https://momswap.produktor.duc
|
||||
```bash
|
||||
cd libs/geo-api-client
|
||||
bun install
|
||||
bun test
|
||||
bun test # unit + integration tests (docs flow)
|
||||
bun run build
|
||||
```
|
||||
|
||||
Integration tests in `test/integration.test.ts` cover the recommended flow: register, login, create collection, create point feature, list features.
|
||||
|
||||
## Public API (current)
|
||||
|
||||
### Class: `GeoApiClient`
|
||||
@@ -80,7 +82,6 @@ Server keys are generated with `./bin/gen-server-keys.sh` and stored in `etc/`.
|
||||
import { GeoApiClient } from "../libs/geo-api-client/dist/index.js";
|
||||
|
||||
const storage = window.localStorage;
|
||||
|
||||
const storageLike = {
|
||||
getItem: (key: string) => storage.getItem(key),
|
||||
setItem: (key: string, value: string) => storage.setItem(key, value),
|
||||
@@ -88,8 +89,14 @@ const storageLike = {
|
||||
};
|
||||
|
||||
const client = new GeoApiClient("https://momswap.produktor.duckdns.org", storageLike);
|
||||
|
||||
const keys = await client.ensureKeysInStorage();
|
||||
|
||||
// Register (ignored if already registered); then login
|
||||
try {
|
||||
await client.registerBySigningServiceKey(keys.publicKey, keys.privateKey);
|
||||
} catch (_) {
|
||||
// Already registered or registration disabled
|
||||
}
|
||||
await client.loginWithSignature(keys.publicKey, keys.privateKey);
|
||||
|
||||
const created = await client.createCollection("My Places");
|
||||
|
||||
Reference in New Issue
Block a user