roe v2.1.2
roe
A single and simplified instance of Egg web framework without clusters and agents, which is more suitable for container-based deployment, such as Docker and Kubernetes.
Install
$ npm i roe
Usage
The usage of roe
is much the same as egg
, and you can dive into the reference of egg directly.
In addition, roe
constructor accepts options.config
as the server configuration, instead of by hardcoding all configurations of different environments in the local project which is an ANTI-PATTERN for ops.
A better practice is to use Kubernetes configmaps and secrets to populate them into process.env
s.
const {Roe} = require('roe')
const app = new Roe({
baseDir: '/path/to',
// We can define roe configurations directly
// by passing options.config, which is a good practise
// for k8s based environment variables management
config: {
keys: process.env.SECRET_KEY,
middleware: [
'body-parser'
]
}
})
app.ready(() => {
app.listen(8888)
})
Or starting with vanilla nodejs http server
require('http')
.createServer(app.callback())
.listen(8888)
new Roe(options)
options
Object
- config
Object | Function(appInfo)
similar asconfig/config.default.js
of egg - extends
Object
which will beObject.assign()
into the instance before loaders are invoked. ...others
Object
other options ofEggCore
exceptoptions.plugins
pluginssince 2.0.0,plugins
should be defined inoptions.config
- config
Creates a roe instance.
License
MIT