1.0.1 • Published 7 years ago
magnolia-rest v1.0.1
magnolia-rest | autowiring koa.js for fast restful services
With magnolia you can set up restful services really fast. You implement the business logic in your controller and reference it in the configuration and magnolia.js will set up the rest for you. You should be able to deploy fast microservices through koa's fast nature or reliable backends for your web apps. Magnolia's approach is that the developer choose the middleware functions through configuration instead of setting up a black magic box for you. Developers can concentrate on the controller logic again and let magnolia.js set up the koa-router and other koa middlewares.
installation
npm install magnolia-rest
or
yarn add magnolia-rest
configuration
you need to pass a config file to magnolia which include the following named exports:
const db = {
// should be your db instance which will be referenced to the koa context
}
const server = {
key: // your ssl private key,
cert: // your ssl certificate,
httpPort: 80, // on this port koa will accept http
httpsPort: 443 // on this port koa will accept https
}
const koa = {
middlewares: {
customName: {
package: '', // any koa middleware
options: [] // constructor options
}
}
}
const endpoints = {
customName: {
method: '', // route endpoint method --> post, get, put, delete
route: '', // route path
middlewares: [] // middleware functions that will be used
}
}
usage
const config = require('./config.js')
const magnolia = require('magnolia-rest')
const app = magnolia.autowire(config)
app.start()