Fix #1
This commit is contained in:
parent
31a224a9fd
commit
1f7078e6ef
3 changed files with 39 additions and 2 deletions
16
example/test.ts
Normal file
16
example/test.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import {MangroveReviews} from "../lib";
|
||||
|
||||
async function example() : Promise<void>{
|
||||
|
||||
const subReviews = await MangroveReviews.getReviews({
|
||||
sub: "geo:51.4954589,11.9659188",
|
||||
q: "verwöner",
|
||||
u: 30,
|
||||
issuers: true,
|
||||
maresi_subjects: true
|
||||
});
|
||||
|
||||
console.log(subReviews.reviews);
|
||||
}
|
||||
|
||||
example()
|
|
@ -59,6 +59,12 @@ export interface QueryParameters {
|
|||
*/
|
||||
maresi_subjects?: boolean
|
||||
|
||||
/**
|
||||
* Only used for 'geo:'-queries
|
||||
* uncertainty in meters
|
||||
*/
|
||||
u?: number
|
||||
|
||||
}
|
||||
|
||||
export class MangroveReviews {
|
||||
|
@ -80,7 +86,7 @@ export class MangroveReviews {
|
|||
.setProtectedHeader({
|
||||
alg: algo,
|
||||
kid,
|
||||
jwk: <any> jwk,
|
||||
jwk: <any>jwk,
|
||||
enc: "utf-8"
|
||||
})
|
||||
.sign(keypair.privateKey);
|
||||
|
@ -127,6 +133,21 @@ export class MangroveReviews {
|
|||
maresi_subjects?: any[],
|
||||
issuers?: any[]
|
||||
}> {
|
||||
if (query.sub?.startsWith("geo:")) {
|
||||
const parts = []
|
||||
if (query.q) {
|
||||
parts.push("q=" + encodeURIComponent(query.q))
|
||||
delete query.q
|
||||
}
|
||||
if (query.u) {
|
||||
parts.push("u=" + query.u)
|
||||
delete query.u
|
||||
}
|
||||
if (parts.length > 0) {
|
||||
query.sub = query.sub + "?" + parts.join("&")
|
||||
}
|
||||
|
||||
}
|
||||
const {data} = await axios.get(`${api}/reviews`, {
|
||||
params: query,
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mangrove-reviews-typescript",
|
||||
"version": "1.1.0",
|
||||
"version": "1.3.0",
|
||||
"description": "A library to interface with Mangrove.reviews",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
Loading…
Reference in a new issue