2.2.5 • Published 3 months ago
@jswork/http-schema v2.2.5
http-schema
Http schema based on next-fetch.
installation
npm install @jswork/http-schema
// adapter: axios
yarn add axios @jswork/next-axios
// adapter: fetch(nodejs)
yarn add node-fetch @jswork/next-fetch
// adapter: fetch(bun/browser)
yarn add @jswork/next-fetch
types
/// <reference types="@jswork/http-schema/dist/@types/type.d.ts" />
usage
import httpSchema from '@jswork/http-schema';
// use Axios
const $api1 = httpSchema({
baseURL: "https://api.github.com",
request: ["", "json"],
resources: [
{
host: "http://dev2.demo.com",
prefix: "v1_",
name: "users",
only: ["index"],
},
{ prefix: "v2_", name: "posts" },
{ name: "roles", except: ["destroy"] },
{ name:'tags'},
{ name:'categories'},
{ name:'pictures'},
],
items: [
{
items: {
login: ["get", "/users/afeiship"],
},
},
],
}, { adapter: 'Axios'});
// use Fetch
import httpSchema from "@jswork/http-schema";
import "@jswork/next-fetch";
const $api2 = httpSchema(
{
baseURL: "https://api.github.com",
request: ["", "json"],
resources: [
{
host: "http://dev2.demo.com",
prefix: "v1_",
name: "users",
only: ["index"],
},
{ prefix: "v2_", name: "posts" },
{ name: "roles", except: ["destroy"] },
{ name: "tags" },
{ name: "categories" },
{ name: "pictures" },
],
items: [
{
items: {
login: ["get", "/users/afeiship"],
},
},
],
},
{ adapter: "Fetch" }
);
license
Code released under the MIT license.
2.2.3
3 months ago
2.2.5
3 months ago
2.2.4
3 months ago
2.2.2
4 months ago
2.2.1
6 months ago
2.1.9
8 months ago
2.1.10
8 months ago
2.1.8
8 months ago
2.1.7
8 months ago
2.1.2
12 months ago
2.1.1
12 months ago
2.1.4
12 months ago
2.1.3
12 months ago
2.1.6
11 months ago
2.1.5
11 months ago
2.0.53
1 year ago
2.0.51
1 year ago
2.0.28
1 year ago
2.0.29
1 year ago
2.0.37
1 year ago
2.0.15
1 year ago
2.0.3
1 year ago
2.0.38
1 year ago
2.0.16
1 year ago
2.0.2
1 year ago
2.0.13
1 year ago
2.0.5
1 year ago
2.0.36
1 year ago
2.0.14
1 year ago
2.0.4
1 year ago
2.0.33
1 year ago
2.0.11
1 year ago
2.0.7
1 year ago
2.0.34
1 year ago
2.0.12
1 year ago
2.0.6
1 year ago
2.0.31
1 year ago
2.0.9
1 year ago
2.0.32
1 year ago
2.0.10
1 year ago
2.0.8
1 year ago
2.0.30
1 year ago
2.0.50
1 year ago
2.0.1
1 year ago
2.0.0
1 year ago
2.0.19
1 year ago
2.0.39
1 year ago
2.0.17
1 year ago
2.0.18
1 year ago
2.0.48
1 year ago
2.0.26
1 year ago
2.0.27
1 year ago
2.0.47
1 year ago
2.0.25
1 year ago
2.0.23
1 year ago
2.0.42
1 year ago
2.0.41
1 year ago
1.0.2
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.1
3 years ago
1.0.0
3 years ago