![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@onepunya/xontol
Advanced tools
XONTOL Xtensible, Optimized, No-dependencies, Transparent, Organized, Lightweight
Simple and readable HTTP requests. Promises-based operation. Integrated assertion features. Support for request pooling. Zero external dependencies. Installation Install with: npm install xontol.
Example Usage
Fetching the NodeJS homepage:
const xontol = require('@onepunya/xontol');
const { status, headers, body, assert } = await xontol('GET', 'https://nodejs.org/en/');
Shorthands XONTOL provides shorthand methods for all HTTP verbs:
method(String url [, Object headers] [, String body])
Posting form data:
const { post } = require('@onepunya/xontol');
const { status, headers, body, assert } = await post('https://example.com/', 'key=value&key=value');
Including headers:
const { put } = require('@onepunya/xontol');
const { status, headers, body, assert } = await put(
'https://example.com/',
{ 'Custom-Header': 'example' },
'key=value&key=value'
);
To disable automatic content and date headers:
const { put } = require('@onepunya/xontol');
const { status, headers, body } = await put(
'https://example.com/',
{ 'no-auto': true, 'Custom-Header': 'example' },
'key=value&key=value'
);
Available HTTP methods in XONTOL:
const xontol = require('@onepunya/xontol');
xontol.get; //=> [function]
xontol.post; //=> [function]
xontol.patch; //=> [function]
xontol.del; //=> [function]
xontol.put; //=> [function]
xontol.head; //=> [function]
xontol.options; //=> [function]
Accessing the raw NodeJS res object, with additional status and body keys:
const { get } = require('@onepunya/xontol');
const res = await get('https://nodejs.org/en/');
Assertions Testing response content:
const { assert } = await get('https://example.com');
// Asserting response body content
assert.body.exactly('expectedContent');
assert.body.contains('expectedContentPart');
assert.body.match(/expectedPattern/);
// Chainable assertions
assert.body.type('application/json').length(42);
// JSON body assertions
assert.body.json
.hasKey('key')
.match('key', 'value')
.empty(); // checks for an empty object
// JSON array assertions
assert.body.json.array
.match(0, 'expectedValue')
.includes('expectedValue')
.length(3)
.empty(); // checks for an empty array
// Status code assertions
assert.status.is(200);
assert.status.not(404);
assert.status.in([200, 201, 202]);
assert.status.notIn([500, 501, 502]);
assert.status.type(2); // checks for 2xx codes
assert.status.notType(5); // checks for not 5xx codes
// Header assertions
assert.headers
.has('authorization')
.match('connection', 'keep-alive');
Authentication
Currently supports Basic and MD5 Digest authentication.
Ensure the server responds with 401 and a WWW-Authenticate header for authentication to work.
Send credentials via the headers object:
const { body } = await post('http://example.com', {
auth: { username: 'user', password: 'pass' }
});
Alternatively, include the credentials in the URL:
const { body } = await post('http://user:pass@example.com');
Pooling Define a request pool with a max size of 10 requests and a 2-second timeout:
const { Pool } = require('@onepunya/xontol');
const myPool = new Pool({ size: 10, timeout: 2000 });
Execute the pool over a set of request bodies:
const bodies = 'abcdefghijklmnopqrstuvwxyz'.split('');
bodies.forEach(body => myPool.post('http://localhost/fail', body));
Wait for all requests to complete:
// Using promises
const responses = await myPool.done();
// Using events
myPool.on('finish', responses => console.log(responses));
Wait for a single request in the pool to complete:
const res = await myPool.post('http://localhost/fail');
Handle each response individually:
myPool.on('response', (req, res) => {
console.log(res.status);
});
Contributing mubh mr.one and all
FAQs
A set of functions for coding easy to read HTTP requests.
The npm package @onepunya/xontol receives a total of 2 weekly downloads. As such, @onepunya/xontol popularity was classified as not popular.
We found that @onepunya/xontol demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.