jkuester:http
Meteor HTTP + EJSON + More
This is a maintained fork of the deprecated Meteor http
package.
On the client it remains unchanged, while on the server it uses node-fetch
instead of request
.
It (mostly) preserves the API of the original HTTP
module.
HTTP
provides an HTTP request API on the client and server. To use
these functions, add the HTTP package to your project with $ meteor add http
.
Additionally it uses EJSON to parse responses, so you can send custom types via your HTTP routes back to the client.
Installation and import
You can install this package via
$ meteor add jkuester:http
and import it into your code via
1import { HTTP } from 'meteor/jkuester:http'
Usage
The package preserves all most of the original API functionality, except
npmRequestOptions
(since request
has been deprecated).
Furthermore, since v3.0 the server calls are fully async
since Meteor 3 dropped fibers.
If you want to send custom types, you need to read about how ejson
works in
Meteor.
Contribution
Your contributions are very welcomed. Please ensure to run tests via:
$ meteor test-packages ./
Testing
We use mocha with meteortesting:mocha
to run the tests.
We also provide a local test project (which is not shipped with the package).
In order to setup the tests you need to change into the test project and install the test dependencies:
$ cd tests && meteor npm install
You can then leverage some of it's npm scripts to test code:
$ meteor npm run lint:code # run linter in check mode $ meteor npm run lint:code-fix # run linter and autofix issues $ meteor npm run test # run test once $ meteor npm run test:watch # run tests in watch mode
Changelog
- 3.0.0
- Full Meteor 3.0 compatibility
- changed tests to use express
- HTTP.call on the server is now native async and uses no callbacks anymore
- 2.3.0
- AbortController is not used by default to comply with original API. If a value greater than -1 is given as timeout then AbortController will be called after that timeout.
- 2.2.0
- Add
HTTP.debug
to API to allow debugging of unsensitive internals
- Add
- 2.1.0
- Added
AbortController
implementation until we get Node >= 16 - Refactored tests to use
meteortesting:mocha
- added bare
tests/
project - use standard linter; code is now standard linted
- added EJSON tests
- added static file serving tests
- Added
- 2.0.1
- replaced
JSON.stringify
andJSON.parse
withEJSON
- replaced
- 2.0.0
- ported original
http
package and replacedrequest
withfetch
- ported original
License
The original package is part of the Meteor core, which is MIT licensed. There is no intention to alter the license so this package preserves the original MIT license.