
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.
Jampper is a simple and straightforward library for mapping RESTful APIs. As it internally uses jQuery's ajax module for performing the requests, almost evertything you can do with jQuery.ajax you can do with Jampper.
$ npm install jampper
$ bower install jampper
Clone the repository and run :
$ npm install
$ node build.js
Regardless of the way you have chosen to install the lib, de dist directory will contain the compiled files.
If you have already loaded the jQuery in your page, you should use the jampper.jquery.js file:
<script src="path/to/jquery.js"></script>
<script src="path/to/jampper/dist/jampper.jquery.js"></script>
Otherwise, the jampper.js file should be used :
<script src="path/to/jampper/dist/jampper.js"></script>
To create a Jampper object of a REST API, you will need to provide the API host and the resources object :
var api = new Jampper('https://api.github.com/', {
users : null,
search : {
repositories : null
},
repos : {
commits : {
sha : null
},
contributors : null
}
});
Note: You can also map resources with file extensions (i.e. users.json). jampper will strip the extension and expose the resource method as users.
In order to perform a GET to the users/rafaeldias :
api.users('rafaeldias').read(function(res) {
...
});
The snippet above is equivalent to :
GET https://api.github.com/users/rafaeldias
In addition to the read method, there are three more methods that by default all resources will inherit in order to perform CRUD operations, each of these methods are mapped to an HTTP verb :
create([options[, callback]]) - POST /resourceupdate([options[, callback]]) - PUT /resourcedelete([options[, callback]]) - DELETE /resourceYou can add or overwrite methods mapped to HTTP verbs by calling the mapMethod method of the Jampper object:
Jampper.mapMethod({
'update' : 'PATCH',
'edit' : 'PUT'
});
Now the next time we call the overwritten update method on a resouce, the HTTP verb PATCH will be used in the request, and the new edit method will send the PUT HTTP verb to the server.
Every CRUD method may receive an object of options as its first parameter. These options are the same as stated in the jQuery ajax documentation.
The arguments of the callback passed to any of the CRUD methods may be different depending on the status of the request.
In case of successful request, the arguments are:
data: The response from the servertextStatus: A string categorizing the status of the request (success, notmodified, error, ...)jqXHR: A superset of the browser's native XMLHttpRequest object. For more information see jQuery's jqXHR sectionIn case of failed requests, the arguments are:
jqXHR: As described above.textStatus: As described above.errorThrown: An exception object. When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error".The done, fail and always methods are also exposed by jampper.
Jampper also exposes the .setup method, so it's possible to configure global ajax properties even if user is not using jQuery.
Jampper is released under the MIT license.
FAQs
Javascript API Mapper
We found that jampper 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.