jaid-core
Combines jaid-logger, essential-config, got, koa and sequelize.
Installation
npm install --save jaid-core@^8.1.0
yarn add jaid-core@^8.1.0
(if configured properly)
npm install --save @jaid/jaid-core@^8.1.0
Usage
Plugins
These optional plugin properties may be called by jaid-core
:
Name | Parameters | Return value |
---|---|---|
constructor |
JaidCore core |
|
setCoreReference |
JaidCore core |
|
getConfigSetup |
Object additionalConfigSetup |
|
preInit |
boolean shouldRemovePlugin |
|
handleConfig |
Object config |
boolean shouldRemovePlugin |
handleKoa |
Koa koa |
|
handleGot |
Got got |
|
collectModels |
Object<string, {default: Model, schema: Object}> |
|
init |
boolean shouldRemovePlugin |
|
postInit |
boolean shouldRemovePlugin |
|
ready |
||
handleLog |
string level , string[] fragments |
JaidCorePlugin
Plugins can inherit from any superclass. When they inherit from JaidCorePlugin, some fields for the instance are automatically set:
.core
.logger
(has.info
,.warn
,.error
,.debug
).config
(Object of the loaded config)
Plugin example:
{ super thisoptions = ...options } { this }
Sequelize model example:
Model /** * @return */ { return thistitle } /** * @type {import("sequelize").ModelAttributes} */const schema = title: type: SequelizeSTRING allowNull: false
Advanced Sequelize model (dynamically generated):
/** * @param {typeof import("sequelize").Model} Model * @param {import("jaid-core").ModelDefinitionContext} context * @return {{default, schema}} */ { /** * @param {Object<string, import("sequelize").Model>} models */ static { AdvancedModel } /** * @return */ { return thistitle } /** * @type {import("sequelize").ModelAttributes} */ const schema = title: type: SequelizeSTRING allowNull: false return default: AdvancedModel schema }
Development
Setting up:
git clone git@github.com:jaid/jaid-core.gitcd jaid-corenpm install
Testing:
npm run test:dev
Testing in production environment:
npm run test
License
MIT License
Copyright © 2020, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)