Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/axe-api/client
axe-api-client is a native JavaScript client for Axe API servers.
https://github.com/axe-api/client
activerecord api api-rest axe-api js-client rest-api restful restful-api
Last synced: 2 days ago
JSON representation
axe-api-client is a native JavaScript client for Axe API servers.
- Host: GitHub
- URL: https://github.com/axe-api/client
- Owner: axe-api
- License: mit
- Created: 2023-04-22T10:11:13.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-28T01:26:05.000Z (23 days ago)
- Last Synced: 2024-10-30T05:42:55.393Z (21 days ago)
- Topics: activerecord, api, api-rest, axe-api, js-client, rest-api, restful, restful-api
- Language: TypeScript
- Homepage: https://axe-api.com/learn/javascript-client-axe-api-client.html
- Size: 978 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
Axe API Client
`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
```ts
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
```js
const response = await api.resource("users").insert({
name: "Karl",
surname: "Popper",
});
```## 📤 Post
```js
const response = await api.resource("users").post({
name: "Karl",
surname: "Popper",
});
```## 🔄 Update
```js
const response = await api.resource("users").update({
name: "Karl",
surname: "Popper",
});
```## 🩹 Patch
```js
const response = await api.resource("users").patch({
name: "Karl",
surname: "Popper",
});
```## ✏️ Put
```js
const response = await api.resource("users").put({
name: "Karl",
surname: "Popper",
});
```## 🗑️ Delete
```js
const response = await api.resource("users").delete();
```## 🔍 Query
```js
import { api } from "axe-api-client";const data = await api.resource("users").paginate();
```## 📝 Fields
```js
const response = await api
.resource("users")
.fields("name", "surname", "email")
.paginate();
```## 🧩 Sorting
```js
const response = await api
.resource("users")
.fields("name", "surname", "email")
.sort("name")
.sort("surname", "DESC")
.sort("email", "ASC")
.paginate();
```## 🚦 Limits
```js
const response = await api.resource("users").paginate({ page: 1, perPage: 25 });
```## ⏩ First
```js
const response = await api.resource("users").first();
```## ❓ Where Conditions
```js
const response = await api.resource("users").where("age", 18).paginate();
``````js
const response = await api
.resource("users")
.where("age", ">=", 18)
.where("name", "Karl")
.paginate();
``````js
const response = await api
.resource("users")
.where("age", ">=", 18)
.orWhere("name", "Karl")
.paginate();
``````js
const response = await api
.resource("users")
.where("age", ">=", 18)
.andWhere("name", "Karl")
.paginate();
``````js
const response = await api
.resource("users")
.where((query) => {
query.where("name", "Karl").where("surname", "Popper");
})
.orWhere("age", ">=", 18)
.paginate();
``````js
const response = await api
.resource("users")
.where("age", "IN", [18, 19, 20])
.paginate();
```> All the [operators](https://axe-api.com/basics/queries/index.html#operators) should be able to used.
## 🔗 Related Data
```js
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](https://contrib.rocks).
## 📜 License
[MIT License](LICENSE)