No description
Find a file
2020-03-01 19:52:04 +01:00
bin Start working on CLI 2020-03-01 19:52:04 +01:00
contents First commit 2020-03-01 17:38:34 +01:00
node_modules Fix readme tables & add automatic mime types to static 2020-03-01 19:02:49 +01:00
plugins Simple logger native plugin 2020-03-01 19:26:30 +01:00
.gitignore Add gitignore 2020-03-01 18:04:10 +01:00
arrayEqual.js First commit 2020-03-01 17:38:34 +01:00
hooks.js Fix native plugin loading 2020-03-01 19:33:11 +01:00
index.js Start working on CLI 2020-03-01 19:52:04 +01:00
package-lock.json Start working on CLI 2020-03-01 19:52:04 +01:00
package.json Start working on CLI 2020-03-01 19:52:04 +01:00
pluginLoader.js Start working on CLI 2020-03-01 19:52:04 +01:00
README.md Add native plugins 2020-03-01 19:24:44 +01:00

Easy plugins

Make web development easier with plugins.

API

Easy plugins is based on Koa, so the ctx variable that's passed is koa's context.

Plugin

The plugin must export object or function. Object should contain these:

Name Descripption
enabled Whether the plugin is enabled and should be used
exec Function to call when plugin is enabled and request matches rules
rules Object containing rules to be passed before calling exec. Can be function, in which case the context is passed and must return boolean (or Promise). If empty, automatically evaluates to true.
Native If native is selected, plugin is registered directly to koa. This means, that the exec gets also function next and ignores rules & enabled properties

If the exported is function, it works as multi-plugin:

The function gets parameter hooks which is a class for managing plugins. Then it should call function hooks.registerPlugin with the following parameters:

  • exec Function to call when request rules matches
  • rules optional, same as in object plugin

Rules

Following rules can be used

Rule Type Description
path String or String[] If path matches exactly.
pathReg Regex Regex to be checked against (must be instance of regex)
method String or String[] Method used
accepts String or String[] Using koa's accepts method. Used as arguments (array expanded)
secure bool If using HTTPS
subdomains String[] If subdomains matches. (compares koa's subdomains)