Gathering detailed insights and metrics for config-req
Gathering detailed insights and metrics for config-req
Gathering detailed insights and metrics for config-req
Gathering detailed insights and metrics for config-req
req-package-json
Load and parse nearest package.json.
serverless-openapi-req-validation
Automatically generate an opeanpi file from your Serverless Framework config file to be used for validation inside your api gateway
req-prop
Lazy require config file. Also get, set, destroy property using dot-notation
npm install config-req
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5 Stars
69 Commits
2 Forks
1 Watchers
4 Branches
4 Contributors
Updated on May 31, 2022
Latest Version
2.1.0
Package Id
config-req@2.1.0
Unpacked Size
22.98 kB
Size
5.88 kB
File Count
15
NPM Version
8.1.0
Node Version
16.13.0
Published on
Aug 21, 2023
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 wrapper based on a config file
This module allows to set up a programmatic HTTP client based on axios. To set it up, it just the url and the HTTP method per environment to be setup ¡et voilà!, a new and shiny HTTP client is ready to be used.
Axios options can be found here;
npm install config-req
1const request = require('config-req'); 2 3// Your env configuration 4const config = { 5 activateAccount: { 6 url: 'http://localhost:5000/v1/account/activate', 7 method: 'post', 8 }, 9}; 10 11const api = request(config); 12 13console.log(api); // returns an object like this { activateAccount: <Promise> } 14 15// Api instance contains a request with the method and URL already configured 16api.activateAccount() 17 .then(response => { 18 console.log(response); // Axios response 19 }); 20
1const request = require('config-req'); 2 3// Your env configuration with nested objects 4const nestedOptions = { 5 registration: { 6 activateAccount: { 7 url: 'http://localhost:5000/v1/account/activate', 8 method: 'post', 9 }, 10 }, 11}; 12 13const api = request(nestedOptions); 14 15console.log(api); // returns an object like this { registration: { activateAccount: <Promise> } } 16 17// Api instance contains a request with the method and URL already configured 18api.registration.activateAccount() 19 .then(response => { 20 console.log(response); // Axios response 21 }); 22
1const request = require('config-req');
2
3const options = {
4 advanced: {
5 withBodyInfo: {
6 url: 'http://localhost:5000/v1/account/activate',
7 method: 'post',
8 },
9 withURLParams: {
10 url: 'http://localhost:5000/v1/account/:id/activate',
11 method: 'get',
12 },
13 withBasicAuth: { // This will affect each call to this endpoint
14 url: 'http://localhost:5000/v1/account/:id/activate',
15 method: 'get',
16 auth: { password: 'pwd', username: 'nickname' },
17 }
18 },
19};
20
21const api = request(options);
22
23api.advanced.withBodyInfo({
24 body: { example: 'example' }, // this is how to send body params
25 query: { example: 'example' }, // this is how to send query params
26 headers: { Authorization: 'Bearer example' }, // this is how to send header params
27})
28 .then(response => {
29 console.log(response); // Axios response
30 });
31
32// This is when we want to handle dynamic url params like this
33// http://localhost:5000/v1/account/:id/activate
34// To change that ID we need to setup the urlParams
35api.advanced.withURLParams({
36 body: { example: 'example' }, // this is how to send body params
37 query: { example: 'example' }, // this is how to send query params
38 headers: { Authorization: 'Bearer example' }, // this is how to send header params
39 params: { id: 'urlParam' },
40})
41 .then(response => {
42 console.log(response); // Axios response
43 });
44
45// Basic auth
46api.advanced.withURLParams({
47 body: { example: 'example' }, // this is how to send body params
48 query: { example: 'example' }, // this is how to send query params
49 headers: { Authorization: 'Bearer example' }, // this is how to send header params
50 params: { id: 'urlParam' }, // This is how to send path params
51 auth: { password: 'pwd', username: 'nickname' }, // this is how you add basic auth for each request
52})
53 .then(response => {
54 console.log(response); // Axios response
55 });
In some scenarios, it might be needed to have a fine-grained control on request or the responses. For example, to refresh a token when it is expired or to handle errors in a specific way. This can be achieved by using the interceptors option provided by Axios. These interceptors can be set-up in the following way:
1const request = require('config-req'); 2 3// Your env configuration 4const config = { 5 activateAccount: { 6 url: 'http://localhost:5000/v1/account/activate', 7 method: 'post', 8 }, 9 10}; 11 12const api = request(config, { 13 interceptors: { 14 request: (config) => { 15 // Do something before request is sent 16 return config; 17 }, 18 response: { 19 success: (response) => { 20 // Do something with response data 21 return response; 22 }, 23 error: (error) => { 24 // Do something with response error 25 return Promise.reject(error); 26 } 27 } 28 } 29}); 30
To contribute you must send a PR. This is how you can run the project as a developer.
Install dependencies
npm install
Execute tests
npm run test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/13 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- 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
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