What is it?
👩💻 A super fast, super customizable library to orchestrate your next application.
What can you use it for?
- A HTTP server
- A chat bot
- A realtime websocket server
- An IRC server
- A MIDI interface
- 👩💭 Anything else you can imagine!
Install it
npm i -S leverage-js
Hello World
For a "Hello World", we'll create a simple http server that responds to requests with a "Hello World".
First, install the HTTP plugin:
npm i -S leverage-plugin-http
Now, we will write an HTTP component and load our component and the HTTP plugin:
const component = Component manager http
Run the above and head over to localhost:3000 to see it in action!
Documentation and Tutorials
Please see the project's wiki 🚀.
API
Leverage.createComponent()
This is an alias for Component.of
and allows you to create a
component instance by passing this method a component definition.
Example:
const component =
Leverage.createMiddleware()
This is an alias for Middleware.of
and allows you to create a
middleware instance by passing this method a middleware definition.
Example:
const middleware =
Leverage.createService()
This is an alias for Service.of
and allows you to create a
service instance by passing this method a service definition.
Example:
const service =
Leverage.createPlugin()
This is an alias for Plugin.of
and allows you to create a
plugin instance by passing this method a plugin definition.
Example:
const plugin =
Leverage.Component
The Component
class lets you create your own components. You can extend it
using the class
syntax or use Component.of
to extend using a normal object.
Example (with class syntax):
{ super thisconfig = type: 'http' }
Component.config
The config
object is a component's special configuration object and defines
how the component should be used.
Component.of()
You can create a component instance by calling this method with component definition object.
Example:
Component
Leverage.Middleware
The Middleware
class lets you create your own middleware. You can extend it
using the class
syntax or use Middleware.of
to extend using a normal object.
Example (with class syntax):
{ super thisconfig = type: 'http' }
Middleware.config
The config
object is a middleware's special configuration object and defines
how the middleware should be used.
Middleware.of()
You can create a middleware instance by calling this method with middleware definition object.
Example:
Middleware
Leverage.Service
The Service
class lets you create your own service. You can extend it
using the class
syntax or use Service.of
to extend using a normal object.
Example (with class syntax):
{ super thisconfig = name: 'myService' }
Service.config
The config
object is a service's special configuration object and defines
how the service should be used.
Service.of()
You can create a service instance by calling this method with service definition object.
Example:
Service
Leverage.Plugin
The Plugin
class lets you create your own plugin. You can extend it
using the class
syntax or use Plugin.of
to extend using a normal object.
Example (with class syntax):
{ super thisconfig = type: 'http' }
Plugin.config
The config
object is a plugin's special configuration object and defines
how the plugin should be used.
Plugin.of()
You can create a plugin instance by calling this method with plugin definition object.
Example:
Plugin
Leverage.manager
Leverage's manager handles loading components, plugins, middleware, and services.
manager.add()
manager.add
will load leverage modules from arguments, arrays, or directory path.
Example:
manager
manager.component()
manager.component
will load a component instance.
Example:
const component = Component manager
manager.plugin()
manager.plugin
will load a plugin instance.
Example:
const plugin = Plugin manager
manager.service()
manager.service
will load a service instance.
Example:
const service = Service manager
manager.middleware()
manager.middleware
will load a middleware instance
Example:
const middleware = Middleware manager