@backwood/backwood
v1.0.11
Published
Feathers provider for Adonis
Readme
Backwood Feathers
Backwood Feathers is a Service Provider for AdonisJS for people that enjoy FeathersJS but can't stand its way of file and coding structuring.
Full docs will come soon
Packages
Installation
npm install --save @backwood/backwoodUsage
Okay, start off by creating a new Adonis Project using the CLI:
adonis new blognow navigate to the server.js file in your root directory and replace .fireHttpServer() with .fire() like so:
server.js
'use strict'
const { Ignitor } = require('@adonisjs/ignitor')
new Ignitor(require('@adonisjs/fold'))
.appRoot(__dirname)
.fire() // <--
.catch(console.error)
then it's also recommended to remove most of the providers, as Feathers will be handling everything else.
start/app.js
const providers = [
'@adonisjs/framework/providers/AppProvider',
'@backwood/backwood'
]Backwood Feathers
Create a mandatory file called feathers.js in the start directory.
start/feathers.js
'use strict'
const Feathers = use('Feathers')
Feathers
.service('message', 'MessageService')app/Services/MessageService
'use strict'
const Service = use('Service')
const Messages = use('Models/Messages')
class MessageService extends Service {
/**
* Assign hooks to a service
*
* @property hooks
* @return {Object}
*/
static get hooks() {
return {
before: {
get: (ctx) => {
// Define get hook
}
}
}
}
get(id, params) {
return Messages.findById(id)
}
}
module.exports = MessageService