
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
mekanika-adapter-http
Advanced tools
Query envelope to HTTP adapter
npm install mekanika-adapter-http
CommonJS:
var http = require('mekanika-adapter-http');
Browser (exposes as HttpAdapter
globals):
<script src="dist/adapter-http.min.js"></script>
The HTTP adapter exposes an .exec( qe, callback )
method and a .config
object property.
http.exec( {do:'find', on:'users'}, function (err, res) {
if (err) throw new Error(err);
console.log( res );
});
The adapter can be run calling exec
and passing it:
(err, res)
parametersThe query envelope MUST sepcify an action: {do:'find'}
which is used to run a superagent call (eg. post()
, get()
etc).
Exec returns the superagent
instance, and passes its results to the callback:
A superagent error object. Information on error handling is available via superagent error docs.
Superagent response object.
Some notable res
properties:
Content-Type
(may be empty)4xx
and 5xx
responsesConfig defaults as follows, each of which can be overridden before calling .exec()
:
exports.config = {
protocol: 'http'
, host: 'localhost'
, port: 80
, contentType: 'application/json'
, withCredentials: false
, headers: {}
}
Config affects how superagent creates the call and where it points to.
The base URL constructed from adapter config is as follows:
protocol:// + host + :port [+ /resource]
The port is omitted from the URL if is the default 80
. The resource is added if one is provided, and ids are appended to the resource URL (separated by commas if several are provided). URL queries are appended if provided by the Qe.
The HTTP request methods map to the default Qe actions as follows:
Qe action | HTTP method |
---|---|
find | GET |
create | POST |
update | POST |
remove | DELETE |
find
and update
requests append Qe identifiers to the URL. So a Qe of {on:'users', ids:['12345']}
, would by default build the following URL:
http://localhost/users/12345
Multiple ids are separated by commas {on:'users', ids:['12345','14421']}
http://localhost/users/12345,14421
Ensure you have installed the development dependencies:
npm install
To run the tests:
npm test
Coverage reports are generated with istanbul (npm install -g istanbul
):
npm run coverage
Copyright 2013-2015 Mekanika
Released under the MIT License (MIT)
FAQs
Mekanika HTTP adapter
The npm package mekanika-adapter-http receives a total of 0 weekly downloads. As such, mekanika-adapter-http popularity was classified as not popular.
We found that mekanika-adapter-http 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.