1.2.0 • Published 2 years ago

@vidiemme/adonis-adminjs v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Adonis AdminJS

npm-image license-image typescript-image

This is a NON-official AdminJS plugin that integrates it to the AdonisJS framework.

AdminJS

AdminJS is an automatic admin interface which can be plugged into your application. You, as a developer, provide database models (like posts, comments, stores, products or whatever else your application uses), and AdminJS generates UI which allows you (or other trusted users) to manage content.

Check out the example application with mongo and postgres models here: https://admin-bro-example-app-staging.herokuapp.com/admin/login

Or visit AdminJS github page.

Installation

Install the package with the command \ npm i adminjs @vidiemme/adonis-adminjs

Configure the package with the command \ node ace configure @vidiemme/adonis-adminjs

Usage

You can edit your AdminJs configuration via the start/adminjs.ts file:

import AdminJS from 'adminjs'

import {AdminjsAdonisInstance} from '@ioc:Vidiemme/Adminjs/Adonis'

const adminJs = new AdminJS({
  databases: [],
  rootPath: '/admin',
})
AdminjsAdonisInstance.buildRouter(adminjs)

Or you can use the AdminJS login screens (authentication is handled by Adonis)

AdminjsAdonisInstance.buildAuthenticatedRouter(adminjs)

The buildRouter and buildAuthenticatedRouter methods return an Adonis Router, so you can then append middleware or manage groups just as you do with other routes.

Route.group(() => {
  AdminjsAdonisInstance
    .buildRouter(new AdminJS())
    .middleware(SomeMiddleware)

  ...
})
  .middleware(SomeGroupMiddleware)

CSRF

In order to use the AdminJS data entry forms you need to disable the csrf control for its routes. \ In the file config/shield.ts add the following code:

exceptRoutes: ({ request }) => request.url().includes('/admin/'), 
1.2.0

2 years ago

1.1.0

2 years ago