npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shagital/adonisjs-crud-generator

v3.0.6

Published

Adonisjs Admin Panel Generator is a package that helps you quickly scaffold your typical CRUD admin interfaces. It generates the admin panel code based on the existing (migrated) table in the database

Downloads

184

Readme

AdonisJS CRUD Generator

npm npm (scoped) NPM

Version [for Adonis v5]

This package allows you easily generate admin dashboard for your existing AdonisJS app. The package generates the following:

  • Migrations
  • Controllers
  • Model
  • Routes
  • Views

Currently Supported

  • MySQL
  • PostgreSQL
  • SQLite

Requirements

  • Adonisjs v5
  • Node >=8 (v14 recommended)
  • Mysql >=5
  • PostgreSQL >=10

Dependencies

Installation

You can install the package via NPM:

npm install @shagital/adonisjs-crud-generator

Or with yarn

yarn add @shagital/adonisjs-crud-generator

Setup

  • Configure the package using node ace configure @shagital/adonisjs-crud-generator. This should update your .adonisrc.json file.
  • Ensure your app is completely setup with @adonisjs/auth and @adonisjs/lucid
  • If you choose to use redis to save tokens, you have to install `@adonisjs/redis'
  • Depending on which hashing algorithm you choose in config/hash.ts, you'll have to install the corresponding dependency e.g phc-bcrypt for bcrypt.
  • The api authentication method has to be functional becuase this package uses auth:api. If you want to save tokens in redis, you have to install @adonisjs/redis
  • Run node ace crud:init --prefix=admin to generate default files for admin panel. Where prefix is the base path for admin routes to be generated
  • Default admin password will be shown to you when the command is done. Copy it somewhere for login. In case you forget or need to change it, you can open database/migrations/admin_default_role_permission.ts to see the password. You can also change password after login
  • Update config/crudGenerator.ts to customise settings

  • The default admin email is [email protected]. You can change the email before running migration
  • Run migration node ace migration:run to create admin user and set up roles and permissions
  • Change to the admin app directory cd resources/views/admin
  • Run npm install or yarn install to install dependencies
  • At this point, your admin dashboard should be ready to use
  • Start the API server: node ace serve or yarn dev
  • Start the frontend app: npm run serve or yarn serve
  • You should be able to change your password after successful login
  • If you encouter CORS error, open config/cors.ts and configure the cors settings correctly.

Usage

To generate CRUD management for table regions, run node ace crud:generate regions and the following will be created

  • Controller app/Controllers/Http/Admin/RegionsController.ts
  • start/routes.ts file will be updated with new routes
  • Mode App/Models/Region.ts model will be created with appropriate relationships hooks
  • A migration file will be generated to add new permissions for the admin
  • Vue files will be generated and the sidebar will be updated with new links

Navigate to your app and you should see the Region menu on the sidebar

Available Commands

  • node ace crud:controller tableName: This creates controller file and route
  • node ace crud:model tableName: This creates model file node ace relationships
  • node ace crud:permission tableName: This creates migration file for crud permissions
  • node ace crud:view tableName: This creates vue files
  • node ace crud:init tableName: This runs all of the above commands

Options

  • --connection: This option allows you specify which DB connection to use for the command e.g node ace crud:controller tableName --connection=sqlite

NB: The connection must have been defined in config/database.ts

  • --migrate: This option is available for the crud:generate and crud:permission commands. It tells the system to automatically run the newly created migration files.
  • --prefix: This option is available when initialising the CRUD with crud:init. It allows you specify a prefix for the admin endpoints that'll be created. If not specified, the system generates a random prefix

Production

Run npm run build or yarn build

  • Your view app should be available on http://<BASE_URL>/<prefix>

Error

If an error occurs while executing any of the command, it'll crash. Simply check your log to find out what went wrong - likely a file/directory permission issue, then run the command again.

Note: Except otherwise stated, the commands always overwrite existing files (with same name)

Screenshots

Login

Dashboard

Profile

List

Form

Todo

  • Add tests

Contributing

If you have a feature you'd like to add, kindly send a Pull Request (PR)

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.