carecentive

How to replace carecentive-core functionality with custom functionality

Carecentive offers you several "core" functionalities, such as basic user authentication and registration.

You may come to the point where this basic functionality does no longer fulfill your needs. Example: If you wish to automatically assign a generated number to a username, instead of letting users specify this name themselves.

In order to replace the core functionality, proceed as follows. This is an example for user registration management, but can equally be applied to all other routes:

Copy core files as templates

Copy:

  • node_modules/carecentive-core/routes/users.js to /routes
  • node_modules/carecentive-core/services/UserService.js to /services
  • node_modules/carecentive-core/models/Users.js to /models

Change dependencies

In each of the copied files, you must now change the dependencies to require the (just copied) carecentive-framework files instead of the carecentive-core files.

Example:

Replace

const User = require('carecentive-core/models/User'); 

with

const User = require('models/User');

You also need to change the main routing in the app.js file. That is, instead of

var usersRouter = require('carecentive-core/routes/users');

use

var usersRouter = require('routes/users');

Adapt files as needed

You can now change the newly copied files in the carecentive-framework folder and adapt them to your needs, add new routes, change routes/services, and so on.