![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
egg-core
Advanced tools
Readme
A core Pluggable framework based on koa.
Don't use it directly, see egg.
Directory structure
βββ package.json
βββ app.js (optional)
βββ agent.js (optional)
βββ app
| βββ router.js
β βββ controller
β β βββ home.js
| βββ extend (optional)
β | βββ helper.js (optional)
β | βββ filter.js (optional)
β | βββ request.js (optional)
β | βββ response.js (optional)
β | βββ context.js (optional)
β | βββ application.js (optional)
β | βββ agent.js (optional)
β βββ service (optional)
β βββ middleware (optional)
β β βββ response_time.js
β βββ view (optional)
| βββ layout.html
β βββ home.html
βββ config
| βββ config.default.js
β βββ config.prod.js
| βββ config.test.js (optional)
| βββ config.local.js (optional)
| βββ config.unittest.js (optional)
β βββ plugin.js
Then you can start with code below
const Application = require('egg-core').EggCore;
const app = new Application({
baseDir: '/path/to/app'
});
app.ready(() => app.listen(3000));
EggLoader can easily load files or directories in your egg project. In addition, you can customize the loader with low level APIs.
Load config/plugin.js
Load config/config.js and config/{serverEnv}.js
If process.env.EGG_APP_CONFIG
is exists, then it will be parse and override config.
Load app/controller
Load app/middleware
Load app/extend/application.js
Load app/extend/context.js
Load app/extend/request.js
Load app/extend/response.js
Load app/extend/helper.js
Load app.js, if app.js export boot class, then trigger configDidLoad
Load agent.js, if agent.js export boot class, then trigger configDidLoad
Load app/service
Retrieve application environment variable values via serverEnv
. You can access directly by calling this.serverEnv
after instantiation.
serverEnv | description |
---|---|
default | default environment |
test | system integration testing environment |
prod | production environment |
local | local environment on your own computer |
unittest | unit test environment |
To get directories of the frameworks. A new framework is created by extending egg, then you can use this function to get all frameworks.
A loadUnit is a directory that can be loaded by EggLoader, cause it has the same structure.
This function will get add loadUnits follow the order:
loadUnit has a path and a type. Type must be one of those values: app, framework, plugin.
{
path: 'path/to/application',
type: 'app'
}
To get application name from package.json
Get the infomation of the application
package.json
package.json
To load a single file. Note: The file must export as a function.
To load files from directory in the application.
Invoke this.loadToApp('$baseDir/app/controller', 'controller')
, then you can use it by app.controller
.
To load files from directory, and it will be bound the context.
// define service in app/service/query.js
module.exports = class Query {
constructor(ctx) {
// get the ctx
}
get() {}
};
// use the service in app/controller/home.js
module.exports = function*() {
this.body = this.service.query.get();
};
Loader app/extend/xx.js to target, For example,
this.loadExtend('application', app);
Param | Type | Description |
---|---|---|
directory | String/Array | directories to be loaded |
target | Object | attach the target object from loaded files |
match | String/Array | match the files when load, default to **/*.js (if process.env.EGG_TYPESCRIPT was true, default to `[ '**/*.(js |
ignore | String/Array | ignore the files when load |
initializer | Function | custom file exports, receive two parameters, first is the inject object(if not js file, will be content buffer), second is an options object that contain path |
caseStyle | String/Function | set property's case when converting a filepath to property list. |
override | Boolean | determine whether override the property when get the same name |
call | Boolean | determine whether invoke when exports is function |
inject | Object | an object that be the argument when invoke the function |
filter | Function | a function that filter the exports which can be loaded |
EggCore record boot progress with Timing
, include:
process.uptime
to record the script start running time, framework can implement a prestart file used with node --require
options to set process.scriptTime
)require
durationStart record a item. If the item exits, end the old one and start a new one.
End a item.
Generate all record items to json
Please open an issue here.
This project follows the git-contributor spec, auto updated at Wed Nov 24 2021 22:24:39 GMT+0800
.
FAQs
A core Pluggable framework based on koa
We found that egg-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.