1.4.4 • Published 4 years ago

jsr-lib-http v1.4.4

Weekly downloads
84
License
-
Repository
-
Last release
4 years ago

jsr-lib-http

Peer dependencies:

About

This library provides utilities for performing AJAX operations using Promise flows.

  • All exports are standard ESM, to keep compatible with @babel/core, and are under the esm bundle.
  • Exporting format is intended for tree shaking, so make sure your webpack/rollup bundle does it to save bytes.

Usage:

Install

In your project (replace version tag as needed):

  • npm i --save-dev "git+ssh://git@bitbucket.org:grupoblidoo/jsr-lib-http.git#VERSION_NUMBER_HERE"

Importing classes

Import wanted objects, for example:

  • import { AjaxHandler } from 'jsr-lib-http/dist/jsr-lib-http.esm.js';

Provided classes

The jsr-lib-http provides:

Services:

  • EndpointService: Service to handle ajax operations. Must be created passing a SuperAgentHttp or ActiveRequester instance.
  • LoggerService: Service used as default when another class has a logging dependency. Just outputs through console.log
  • UrlService: Service with static methods to perform or query data from URLs.
  • ValidatorService: Validates parameters, using the revalidator module.

IO:

  • HttpInterface: "Interface" class for SuperAgentHttp and ActiveRequester classes.
  • SuperAgentHttp: Performs basic AJAX/REST operations, on top of superagent.
  • ActiveRequester: Performs active request operations. It's built on top of SuperAgentHttp.

Middleware:

  • AjaxMiddleware: Pseudo-interface for middleware classes.
  • LogOutOnCodesMiddleware: Changes window.location if ajax returns any of the specified codes.
  • LogOutOnCodeRangesMiddleware: Changes window.location if ajax returns a code in one of the specified ranges.

Interfaces:

  • AjaxHandler: Generic AJAX handler.
  • AjaxAction: Generic AJAX action.

TODO: Active requests

Developing the library

  • Keep 100% test coverage. It is forced by config.
  • Keep 0 (ZERO) warnings under /src

If you don't do any of these, your IDE will be self-destructed.

How to publish

// 0. Login npm
npm login

// 1. Commit your changes
git add .
git commit -m "RC-XXXX feat: yay new feat"

// 2. Build the dist file that we'll publish
npm run build

// 3. Generate a new tag
npm run rc // Release candidate, for testing purposes. // See: How to make a release candidate tag below

OR for final version

npm run upgrade-{{type}} // type = patch, minor or major. See Type of versions below

// 4. Let's publish de package
npm publish
// This will publish all the content of your /dist folder generated in step 2

// IMPORTANT: 5. When you're done, please create a PR and merge your changes to master
git push // If you haven't done it

Important: If you are testing your changes in other projects, read How to make a release candidate tag below.

Type of versions

  • Patch: npm run upgrade-patch
  • Minor: npm run upgrade-minor (fixes, improvements, small features etc...)
  • Major: npm run upgrade-major (Big/Crashing features nor changes)

How to make a release candidate tag

This is a functionality that makes you able to test your changes in other projects. While not affecting other people working in the same library.

1- Make changes in your branch

2- Commit changes to clean your work directory

git add .
git commit -m "RC-XXXX: my message"

3- Run npm run rc

The last step would be to create a new RC tag for the next version, something like: 1.0.1-next.0 and it will be like this until you release a normal version

1.4.4

4 years ago

1.4.3

4 years ago