T
T
Timur Evgazhukov2020-09-15 09:42:29
Node.js
Timur Evgazhukov, 2020-09-15 09:42:29

How to organize plugins for a site that is written under nodejs?

There is a project that is written in js under nodejs with a vuejs front end and now there is a need to add functionality that would allow adding plugins written by third-party developers, such as in well-known CMS like wordpress. It should be possible to load/delete/enable/disable these plugins through the internal admin without restarting the server itself.
Please advise how to organize such an opportunity and give links to posts where this is described.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-09-16
@Robur

you need to think over and develop api for plugins - loading, initialization, transferring data from the plugin to the system and back, responding to events, and so on.
This api depends on how you have everything arranged there and what you want plugins to do.
can be anything from very simple to very complex.
very roughly the scheme is as follows:
- adding/registration of plug-ins. in its simplest form - by adding plugin files to the desired folder.
- activation/deactivation. In its simplest form, store a list of activated ones in the database, or symlinks in a folder from where everything is imported.
- plugin initialization - after loading the plugin, its initialization method is called, everything is passed to it, it does what the plugin needs to start
- the plugin registers its hooks in the system.
- the system during operation, in the right place, calls the hooks from the plugin, they do what they need. For example, loading a user - a hook is called, a user is passed to it, the plugin adds some new fields there, and returns it back. The user with new fields goes further in the system
- if the plugin has been deactivated, the corresponding method is called for it, then the plugin is removed from the active list,
further it can be developed and changed as you like, it depends on your needs and goals.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question