adonis-apidoc
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -7,41 +7,4 @@ ## Registering provider | ||
const providers = [ | ||
'adonis-imperium/providers/ImperiumProvider' | ||
'adonis-apidoc/providers/ApiDocProvider' | ||
] | ||
``` | ||
## Registering middleware | ||
Add the middleware `Adonis/Middleware/ImperiumInit` in the `start/kernel.js` file in `globalMiddleware` array **after** `AuthInit`. | ||
Add the middlewares `Adonis/Middleware/Is` and `Adonis/Middleware/Can` in the `start/kernel.js` file in `namedMiddleware` array. | ||
```js | ||
// start/kernel.js | ||
const globalMiddleware = [ | ||
... | ||
'Adonis/Middleware/AuthInit', | ||
'Adonis/Middleware/ImperiumInit', | ||
... | ||
] | ||
const namedMiddleware = { | ||
... | ||
is: 'Adonis/Middleware/Is', | ||
can: 'Adonis/Middleware/Can' | ||
... | ||
} | ||
``` | ||
## Loading acl.js | ||
Add the `start/acl.js` file to your Ignitor starting script. | ||
```js | ||
// server.js | ||
new Ignitor(require('@adonisjs/fold')) | ||
.appRoot(__dirname) | ||
.preLoad('start/acl') | ||
.fireHttpServer() | ||
.catch(console.error) | ||
``` |
{ | ||
"name": "adonis-apidoc", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "AdonisJs API Documentation out of the box.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -6,2 +6,9 @@ 'use strict' | ||
class ApiDocProvider extends ServiceProvider { | ||
register () { | ||
this.app.bind('Cmty/Controllers/ApiDocController', function () { | ||
const ApiDocController = require('../src/Controllers/ApiDocController') | ||
return new ApiDocController() | ||
}) | ||
} | ||
boot () { | ||
@@ -11,4 +18,3 @@ if (process.env.NODE_ENV !== 'development') return | ||
const Route = use('Adonis/Src/Route') | ||
Route.get('/api/doc', 'ApiDocController.render') | ||
Route.get('/api/doc', '@provider:Cmty/Controllers/ApiDocController.render') | ||
} | ||
@@ -15,0 +21,0 @@ } |
# Adonis ApiDoc | ||
> This package is an **authorization provider** built on top of [Imperium](https://github.com/cmty/imperium) and inspired by [adonis-guard](https://github.com/RomainLanz/adonis-guard). | ||
> TAdonisJs API Documentation out of the box. | ||
[![npm version](https://img.shields.io/npm/v/adonis-imperium.svg)](https://www.npmjs.com/package/adonis-imperium) | ||
[![license](https://img.shields.io/github/license/adonis-imperium/imperium.svg)](https://github.com/cmty/adonis-imperium/blob/master/LICENSE.md) | ||
[![npm version](https://img.shields.io/npm/v/adonis-apidoc.svg)](https://www.npmjs.com/package/adonis-apidoc) | ||
[![license](https://img.shields.io/github/license/adonis-apidoc/apidoc.svg)](https://github.com/cmty/adonis-apidoc/blob/master/LICENSE.md) | ||
## Documentation | ||
[http://imperium.dimerapp.com/docs/master/adonisjs](http://imperium.dimerapp.com/docs/master/adonisjs) | ||
## Getting Started | ||
@@ -17,11 +13,11 @@ | ||
```bash | ||
> adonis install adonis-imperium | ||
> adonis install adonis-apidoc | ||
``` | ||
Follow instructions that are displayed ([or read them here](https://github.com/cmty/adonis-imperium/blob/master/instructions.md)). | ||
Follow instructions that are displayed ([or read them here](https://github.com/cmty/adonis-apidoc/blob/master/instructions.md)). | ||
Learn more in the [docs](http://imperium.dimerapp.com/docs/master/adonisjs). | ||
Learn more in the [docs](http://apidoc.dimerapp.com/docs/master/adonisjs). | ||
## License | ||
[MIT](https://github.com/cmty/adonis-imperium/blob/master/LICENSE.md) | ||
[MIT](https://github.com/cmty/adonis-apidoc/blob/master/LICENSE.md) |
@@ -1,13 +0,13 @@ | ||
/* istanbul ignore file */ | ||
'use strict' | ||
const path = require('path') | ||
const { chain, find, capitalize, upperCase, startsWith, endsWith } = require('lodash') | ||
const Config = use('Config') | ||
const Route = use('Adonis/Src/Route') | ||
const Imperium = use('Adonis/Addons/Imperium') | ||
const Imperium = use('Imperium') | ||
class ApiDocController { | ||
render ({ view }) { | ||
const name = Config.get('app.appName') | ||
const roles = Imperium ? Imperium.roles() : [] | ||
@@ -55,5 +55,2 @@ | ||
.groupBy((route) => { | ||
if (['/me'].indexOf(route.name) !== -1) return 'users' | ||
if (['/login/github', '/github/callback', '/logout'].indexOf(route.name) !== -1) return 'authentication' | ||
const name = route.name | ||
@@ -70,3 +67,3 @@ .replace('.index', '') | ||
return view.render('apidoc', { routes, roles }) | ||
return view.render(path.join(__dirname, './views/apidoc.edge'), { routes, roles, name }) | ||
} | ||
@@ -73,0 +70,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70
9281
23