0.8.0 • Published 8 months ago

quidjs v0.8.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 months ago

Quidjs

pub package

A requests library for the Quid json web tokens server

This library transparently manage the requests to api servers. If a server returns a 401 Unauthorized response when an access token is expired the client library will request a new access token from a Quid server, using a refresh token, and will retry the request with the new access token

yarn add quidjs
# or
npm install quidjs

Usage

import { useQuidRequests } from "quidjs";

const quid = useQuidRequests({
  namespace: "my_namespace",
  quidUri: "https://localhost:8082", // quid server url
  serverUri: "https://localhost:8000", // url of your backend
  verbose: true,
});

// login the user
await quid.login("user", "pwd");

// use the quid instance to request json from the backend
// GET request
const response: Record<string,any> = await quid.get<Record<string,any>>("/api/get");
console.log("Backend GET response:", response)
// POST request
const payload = {"foo": "bar"};
const response2: Record<string,any> = await quid.post<Record<string,any>>("/api/post", payload);
console.log("Backend POST response:", response2)

Examples

Run the tests

Create a test namespace in a Quid instance and create a user. Open tests/src/conf.ts and update the namespace key and credentials. Then run the tests:

yarn test
0.8.0

8 months ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago