Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Proposal for API changes #3

Open
thetutlage opened this issue Jun 27, 2019 · 0 comments
Open

Proposal for API changes #3

thetutlage opened this issue Jun 27, 2019 · 0 comments

Comments

@thetutlage
Copy link

The hash module is a great package when using standalone. However, I was thinking of making handful of changes to make it jell well in the AdonisJs ecosystem.

Using AdonisJs manager

The @poppinss/manager package is something I am planning to use for every component, which uses the builder pattern or has driver based API.

The package assumes that you will make use of the IoC container, which makes sense for AdonisJs, but not for packages to be used standalone. To encounter that, we need to write bit of extra code and hide the IoC container layer from the end user.

Main hash class

class Hash extends Manager {
  constructor (container) {
    super(container)
  }
}

Now when we register the Hash class as a provider to the IoC container, we can provider the Ioc container reference to the class constructor.

When using it standalone, we can wrap this class inside another class.

class HashStandalone extends Hash {
  constructor () {
    super({}) // passing empty object
  }
}

The HashStandalone is shared for standalone usage.

Using driver over use.

Since, I am planning to keep the API identical everywhere, I would love to replace use with driver method, and driver method already exists on the Manager class.

Using PHC string format

The Phc string format encodes the hashing info within the hash string and it makes it possible to upgrade older hash values whenever required.

Adding needsRehash

You shared this with me earlier and I think, it's a good idea to add support for needsRehash and we will need PHC string format for that.

WHAT YEAH THINK?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant