Skip to content
/ client Public

axe-api-client is a native JavaScript client for Axe API servers.

License

Notifications You must be signed in to change notification settings

axe-api/client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f6aaea0 · Sep 28, 2024

History

62 Commits
Sep 25, 2024
Feb 11, 2024
Sep 25, 2024
Sep 28, 2024
Sep 28, 2024
Apr 22, 2024
Apr 22, 2024
Apr 22, 2023
Jul 23, 2023
Sep 28, 2024
Apr 22, 2023
Dec 15, 2023
Sep 25, 2024
Apr 22, 2024
Sep 25, 2024
Sep 28, 2024
Sep 28, 2024
Sep 28, 2024
Sep 28, 2024
Apr 22, 2024

Repository files navigation


Markdownify
Axe API Client
npm version

axe-api-client is a native JavaScript client for Axe API servers.

You can send insert, update, delete, and fetch data from Axe API servers without pain. axe-api-client has advanced query support with the active record pattern.

⚙️ Config

import { api, IRequest } from "axe-api-client";

api.setConfig({
  baseURL: "https://bookstore.axe-api.com/api/v1",
  headers: {},
  params: {},
});

api.interceptors.addRequest((request: IRequest) => {
  return request;
});

api.interceptors.addResponse((response: Response) => {
  // console.log(response);
});

➕ Insert

const response = await api.resource("users").insert({
  name: "Karl",
  surname: "Popper",
});

📤 Post

const response = await api.resource("users").post({
  name: "Karl",
  surname: "Popper",
});

🔄 Update

const response = await api.resource("users").update({
  name: "Karl",
  surname: "Popper",
});

🩹 Patch

const response = await api.resource("users").patch({
  name: "Karl",
  surname: "Popper",
});

✏️ Put

const response = await api.resource("users").put({
  name: "Karl",
  surname: "Popper",
});

🗑️ Delete

const response = await api.resource("users").delete();

🔍 Query

import { api } from "axe-api-client";

const data = await api.resource("users").paginate();

📝 Fields

const response = await api
  .resource("users")
  .fields("name", "surname", "email")
  .paginate();

🧩 Sorting

const response = await api
  .resource("users")
  .fields("name", "surname", "email")
  .sort("name")
  .sort("surname", "DESC")
  .sort("email", "ASC")
  .paginate();

🚦 Limits

const response = await api.resource("users").paginate({ page: 1, perPage: 25 });

⏩ First

const response = await api.resource("users").first();

❓ Where Conditions

const response = await api.resource("users").where("age", 18).paginate();
const response = await api
  .resource("users")
  .where("age", ">=", 18)
  .where("name", "Karl")
  .paginate();
const response = await api
  .resource("users")
  .where("age", ">=", 18)
  .orWhere("name", "Karl")
  .paginate();
const response = await api
  .resource("users")
  .where("age", ">=", 18)
  .andWhere("name", "Karl")
  .paginate();
const response = await api
  .resource("users")
  .where((query) => {
    query.where("name", "Karl").where("surname", "Popper");
  })
  .orWhere("age", ">=", 18)
  .paginate();
const response = await api
  .resource("users")
  .where("age", "IN", [18, 19, 20])
  .paginate();

All the operators should be able to used.

🔗 Related Data

const response = await api
  .resource("users")
  .with("posts{comments{id|content}}")
  .paginate();

⚡ Quick where functions

We can use the following query where functions:

  • whereNot("id", 1)
  • whereLike("name", "*john*")
  • whereNotLike("name", "*john*")
  • whereIn("type", [1, 2, 3])
  • whereNotIn("type", [1, 2, 3])
  • whereBetween("type", 1, 3)
  • whereNotBetween("type", 1, 3)
  • whereNull("age")
  • whereNotNull("age")

👥 Contributors

Made with contrib.rocks.

📜 License

MIT License