Inheritance
Last updated: 4 - 5 - 2019

Another great feature that come with ZinkyJS is modules' inheritance. With it, you can make use of a module's operations in another one without the need to rewrite them.

Example

Create a 'login' module with this operation:
 POST_login(req, res, next) {
  // The code to login...
}

Now, we want to create a module 'auth' that uses this same operation of 'login' module and add a new one specific to register.
We'll need to make 'app_modules/auth/index.js' look like this:

 const Login = require('../login');

class Auth extends Login {

  POST_register(req, res) {
    // The code to register...
  }

}

module.exports = Auth;

We can now post to /auth/register as well as you can post /auth/login.