Gathering detailed insights and metrics for axios-endpoints
Gathering detailed insights and metrics for axios-endpoints
Gathering detailed insights and metrics for axios-endpoints
Gathering detailed insights and metrics for axios-endpoints
@devlander/rawstack-axios-module
A module used for the raw outdoors with endpoints and types
axios-endpointa
Axios endpoints helps you to create mor concise endpoint mapping with axios.
axios-actions
Bundle endpoints as callable, reusable services
axios-ratelimiter
A module to handle querying ratelimited endpoints using Axios.
Axios endpoints helps you to create a more concise endpoint mapping with axios.
npm install axios-endpoints
Typescript
Module System
Node Version
NPM Version
71.7
Supply Chain
99.3
Quality
76
Maintenance
100
Vulnerability
100
License
TypeScript (88.81%)
JavaScript (11.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
42 Stars
284 Commits
1 Forks
11 Branches
1 Contributors
Updated on May 10, 2024
Latest Version
1.0.3
Package Id
axios-endpoints@1.0.3
Unpacked Size
28.46 kB
Size
5.55 kB
File Count
18
NPM Version
8.8.0
Node Version
18.1.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Axios endpoints helps you to create a more concise endpoint mapping with a simple but flexible api. It is as wrapper over axios.
Before anything, install axios-endpoints
1npm install --save axios #axios is a peer dependency 2npm install --save axios-endpoints
For a more complete usage of axios settings, you may use the Factory.
1import axios from "axios"; 2import EndpointFactory from "axios-endpoints"; 3 4const axiosInstance = axios.create({ 5 baseURL: "https://localhost:8080/api" 6}); 7 8const Endpoint = EndpointFactory(axiosInstance); 9 10const cityEndpoint = new Endpoint("/city"); // GET https://localhost:8080/api/city 11const postEndpoint = new Endpoint(({id = ""}) => "/post/" + id); 12 13// Header changing example 14function setAuthorization(MYTOKEN){ 15 axiosInstance.defaults.headers.common["Authorization"] = MYTOKEN; 16} 17 18 19 20function getCityList(callback) { 21 cityEndpoint.get().then(response=>{ 22 callback(response.data); 23 }).catch(e=>{ 24 console.log("That didnt go well"); 25 }); 26} 27 28// do you like async stuff? so take this async example 29async function getCityList(){ 30 try{ 31 const { data } = await cityEndpoint.get(); 32 return data; 33 } catch (e) { 34 console.log("That didnt go well"); 35 } 36} 37 38
The fastest way to use axios-endpoints. ideal when you dont want to set any axios configs:
1// endpoints.js 2import { Endpoint } from "axios-endpoints"; 3 4export const userEndpoint = new Endpoint("https://localhost:8080/api/user"); 5 6 7// anotherfile.js 8import { userEndpoint } from "./endpoints"; 9 10async function getUserList(){ 11 try{ 12 const { data } = await userEndpoint.get(); 13 return data; 14 } catch (e) { 15 console.log("That didnt go well"); 16 } 17} 18 19
You can user either .get
.post
.put
and .delete
as well:
1 2const cityEndpoint = new Endpoint("/city"); 3 4const { data } = await cityEndpoint.get(); // GET https://localhost:8080/api/city 5const { data } = await cityEndpoint.get({ 6 params: {country:"brazil"} 7}); // GET https://localhost:8080/api/city?country=brazil 8 9 10const { data } = await cityEndpoint.post({ 11 name: "Hortolandia", 12 country: "Brazil", 13 hazardLevel: 10000 14}, { 15 params: { someParam: "icecream" } 16}); 17/* 18curl --request POST \ 19 --url https://localhost:8080/api/city?someParam=icecream \ 20 --header 'Content-Type: application/json' \ 21 --data '{ 22 "name": "Hortolandia", 23 "country": "Brazil", 24 "hazardLevel": 10000 25 }' 26*/
Not always your endpoint will be represented by a fixed string. For that, uri params exists.
1const postEndpoint = new Endpoint(({postId = ""}) => "/post/" + postId) 2 3const { data } = await postEndpoint.get({ 4 uriParams: { 5 postId: 1 6 } 7}); // GET https://localhost:8080/api/post/1
For more information about parameters and returned values, check the API section.
EndpointFactory
1import axios from "axios"; 2import EndpointFactory from "axios-endpoints" 3 4const axiosInstance = axios.create(config); 5const Enpoint = EndpointFactory(axiosInstance);
Type: function
Parameters | |
---|---|
axiosInstance | Axios instance |
axiosInstance
is generated via axios.create
function. For more information, check axios documentation.
Return: Endpoint
Endpoint
1import axios from "axios"; 2import EndpointFactory from "axios-endpoints" 3 4const axiosInstance = axios.create(config); 5const Enpoint = EndpointFactory(axiosInstance);
Type: class
Constructor Parameters | Type |
---|---|
endpointIdentifier | String or Function any => String |
endpoint#get(options)
endpoint#post(payload, options)
endpoint#put(payload, options)
endpoint#patch(payload, options)
endpoint#delete(options)
Parameters | Type |
---|---|
options | The same object as the Request Config with the extra property uriParams . You may use params and uriParams more often. |
payload | The object that will be carried as json payload of the request |
If you got so far reading this README, you are maybe thinking about contributing. Pull requests are welcome.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/2 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More