@expressive-tea/plugin v1.0.3
Expressive Tea
A Typescript Framework to create RESTful Services.
Description
Allows to user create own recipes of their own configurations for Expressive Tea Projects which will helps to agilize and repeatable patterns. In example: A User can make plugin configurations for a REST API projects and include all the express middlewwares and configurations and make it reusable. Also allows users shares their best flavored settings for new projects.
This Package is only COMPATIBLE with
Expressive Tea >= 1.1.x
Installation
$ npm install @expressive-tea/plugin
Usage
Create a new file import the Plugin
class and the Boot Stages
as is showing in the next example:
import { Plugin, BOOT_STAGES } from "@expressive-tea/plugin"
import { Stage } from "@expressive-tea/plugin/decorators"
import { Express } from "express"
export default class PluginTest extends Plugin {
protected name: string = "Plugin Test"
protected priority: number = 100
protected dependencies: string[] = []
@Stage(BOOT_STAGES.BOOT_DEPENDENCIES)
test(server: Express) {
server.use((req, res, next) => {
console.log("TEST from Plugin")
next()
})
}
@Stage(BOOT_STAGES.APPLICATION)
secondTest(server: Express) {
server.use((req, res, next) => {
console.log("SECOND TEST from Plugin")
next()
})
}
}
Then in the file where you have setting up your Expressive Tea project you need to use the Pour
decorator and made an instance of your
plugin to attach it to current project.
@ServerSettings({
port: 8080
})
@Pour(new PluginTest())
class Bootstrap extends Boot {}
const bootstrap = new Bootstrap()
bootstrap.start()
Documentation
Abstract Class Plugin
Placeholder abstract class to allow define staged methods and main information.
Properties
Modifier | Name | Type | Description | Default |
---|---|---|---|---|
Protected | name | String | Defined the plugin name. | Class Name |
Protected | priority | Number | Defined Priority order. | 999 |
Protected | dependencies | String[] | Defined Plugin Dependencies. | [] |
abstract class Plugin {
readonly settings: ExpressiveTeaPluginSettings;
protected name: string;
protected priority: number;
protected dependencies: string[];
private static isDependencyRegistered;
constructor(settings?: ExpressiveTeaPluginSettings);
getRegisteredStage(stage: BOOT_STAGES): any;
}
Stage Method Decorator
Define a Method that will be run it on a Expressive Tea defined Boot Stages.
@Stage(stage: BOOT_STAGES, required?: Boolean): (target: any, propertyKey: any, descriptor: any) => void;
method(server: Express): void;
Interfaces
interface ExpressiveTeaServerProps {
port?: number;
[key: string]: any;
}
interface ExpressiveTeaPluginProps {
name: string;
priority: number;
}
interface ExpressiveTeaPluginSettings {
priority?: number;
name?: string;
dependencies?: string[];
[key: string]: any;
}
Support
If you are experience any kind of issues we will be happy to help. You can report an issue using the issues page or the chat. You can also ask questions at Stack overflow using the expressive-tea
tag.
If you want to share your thoughts with the development team or join us you will be able to do so using the official the mailing list. You can check out the wiki to learn more about Expressive Tea internals or check our documentation.
License
This project is licensed under the Apache-2.0 License - see the LICENSE file for details
Disclaimers
The banner and the logo is a derivate work Designed by Freepik