
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
rest-url-builder
Advanced tools
Build rest urls by substituting the named and query parameters.
yarn add rest-url-builder (recommended) || npm install --save rest-url-builder.
Build better rest url's by substituting the parameters using the provided context. Few advantages are
import { RestURLBuilder } from 'rest-url-builder
// const RestURLBuilder = require('rest-url-builder);
let urlBuilder = new RestURLBuilder();
urlBuilder.buildRestURL('urlString');
urlBuilder.setNamedParameter('parameterName', parameterValue);
urlBuilder.setQueryParameter('parameterName', queryParameterValue);
urlBuilder.get();
All examples are Typescript based.
Example 1: Get users
// user-rest-api.service.ts
import { RestURLBuilder } from 'rest-url-builder';
class UserRestAPI {
private usersURL = 'https://fromsomewhere.com/users/:userId';
private urlBuilder = new RestURLBuilder();
getUsers(userId: number) { // userId = 4
let builder = this.urlBuilder.buildRestURL(this.userURL);
builder.setNamedParameter('userId', ''+userId );
let finalURL = builder.get(); // produces https://fromsomewhere.com/users/4
http.get(finalURL); // psuedo
}
}
Example 2: (build on top of example 1) getUsers of a certain organization
private organizationUsersURL = 'https://fromsomewhere.com/organizations/:organizationId/users/:userId';
getUsers(organizationId: number, userId: number) {
let builder = this.urlBuilder.buildRestURL(this.organizationUsersURL);
builder.setNamedParameter('userId', ''+userId);
builder.setNamedParameter('organizationId', ''+organizationId);
let finalURL = builder.get(); // produces https://fromsomewhere.com/organizations/3/users/110
http.get(finalURL); // psuedo
}
Example 3: query parameter example - The advantage here is the unused query parameters are removed from the final url. No need to check with if else or run it with for (queryParam in queryParams). Produces nice urls.
private filterUserByRoleAndName = 'https://fromsomewhere.com/organizations/:organizationId/users?role=:role&name=:name';
getUsers(organizationId: number, role: string, name: string) { // organizationId = 3, role ="manager", name=null
let builder = this.urlBuilder.buildRestURL(this.filterUserByRoleAndName);
builder.setNamedParameter('organizationId', organizationId);
builder.setQueryParameter('role', role);
builder.setQueryParameter('name', name);
let finalURL = builder.get(); // produces https://fromsomewhere.com/organizations/3/users?role=manager (since name is null, it will not get appeneded to the url)
http.get(finalURL); // psuedo
}
MIT
FAQs
A rest url builder with easy parameter substitution
The npm package rest-url-builder receives a total of 361 weekly downloads. As such, rest-url-builder popularity was classified as not popular.
We found that rest-url-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.