@backwood/rest
v1.0.6
Published
Feathers REST API provider for Adonis
Downloads
33
Readme
Backwood Feathers REST
Backwood Feathers is a Service Provider for AdonisJS
Full docs will come soon
This is a service provider for providing REST to Feathers
Packages
Installation
npm install --save @backwood/rest
Usage
Add @backwood/rest
to the app providers in start/app.js
Backwood REST
Create a mandatory file called rest.js
in the start
directory.
start/rest.js
'use strict'
const Rest = use('Rest')
exports.globalMiddleware = [
Rest.express.json(),
Rest.express.urlencoded({ extended: false })
]
exports.namedMiddleware = {
auth: (req, res, next) => {
return !req.user
? next(false)
: next()
},
guest: (req, res, next) => {
return req.user
? next(false)
: next()
}
}
Rest
.service('user', 'UserService')
.group(() => {
Rest.get('/login', 'LoginController.get')
}).options({
middleware: 'guest',
prefix: 'guest',
namespace: 'Guest'
})