npm.io
1.0.1 • Published 8 years ago

backwood-feathers-rest

Licence
MIT
Version
1.0.1
Deps
3
Vulns
0
Weekly
0
Stars
1
DeprecatedThis package is deprecated

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

Installation

npm install --save backwood-feathers backwood-feathers-rest

yarn add --save backwood-feathers backwood-feathers-rest

Usage

Okay, start off by creating a new Adonis Project using the CLI:

adonis new blog

now navigate to the server.js file 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 and add the Backwood providers to the application

start/app.js

const providers = [
    'backwood-feathers',
    'backwood-feathers-rest'
]
Backwood Feathers
'use strict'

const primus = use('@feathersjs/primus')

const Feathers = use('Feathers')

Feathers
  .configure(primus({ transformer: 'websockets' }))
  .service('message', 'MessageService').hooks('MessageHooks')
  .service('products', 'ProductService').hooks('ProductService')
Backwood Feathers REST API
'use strict'

const Rest = use('Rest')

exports.globalMiddleware = [
  Rest.express.json()
]

exports.namedMiddleware = {
  test: (req, res, next) => {
    console.log('test')
    next()
  }
}

Rest
  .group(() => {
    Rest.get('/test', 'TestController.get')
  }).middleware('test')