### Full Example: AdminJS with SQL Adapter and Express Source: https://docs.adminjs.co/installation/adapters/sql A complete example demonstrating the setup of AdminJS with the SQL adapter, Express.js, and routing. ```typescript import AdminJS from 'adminjs' import express from 'express' import Plugin from '@adminjs/express' import { Adapter, Database, Resource } from '@adminjs/sql' AdminJS.registerAdapter({ Database, Resource, }) const start = async () => { const app = express() const db = await new Adapter('postgresql', { connectionString: 'postgres://adminjs:adminjs@localhost:5432/adminjs_panel', database: 'adminjs_panel', }).init(); const admin = new AdminJS({ resources: [ { resource: db.table('users'), options: {}, }, ], }); admin.watch() const router = Plugin.buildRouter(admin) app.use(admin.options.rootPath, router) app.listen(8080, () => { console.log('app started') }) } start() ``` -------------------------------- ### Install AdminJS Leaflet Integration Source: https://docs.adminjs.co/basics/features/leaflet-maps Follow these steps to clone the repository, install dependencies, build the project, and set up the example application. ```bash $ git clone https://github.com/SoftwareBrothers/adminjs-leaflet.git $ cd adminjs-leaflet $ yarn install $ yarn build $ cd example-app $ yarn install $ docker-compose up -d $ yarn start ``` -------------------------------- ### Setup AdminJS with Koa (JavaScript) Source: https://docs.adminjs.co/installation/plugins/koa Basic setup for AdminJS in a Koa application using JavaScript. Ensure AdminJS and Koa are installed. ```javascript import AdminJS from 'adminjs' import AdminJSKoa from '@adminjs/koa' import Koa from 'koa' const PORT = 3000 const start = async () => { const app = new Koa() const admin = new AdminJS({ resources: [], rootPath: '/admin', }) const router = AdminJSKoa.buildRouter(admin, app) app .use(router.routes()) .use(router.allowedMethods()) app.listen(PORT, () => { console.log(`AdminJS available at http://localhost:${PORT}${admin.options.rootPath}`) }) } start() ``` -------------------------------- ### Simple Hapi Setup - Typescript Source: https://docs.adminjs.co/installation/plugins/hapi Basic setup for the AdminJS Hapi plugin in a Typescript Hapi application. Ensure AdminJS packages are installed. ```typescript import AdminJSHapi, { ExtendedAdminJSOptions } from '@adminjs/hapi' import Hapi from '@hapi/hapi' const PORT = 3000 const start = async () => { const server = Hapi.server({ port: PORT }) const adminOptions: ExtendedAdminJSOptions = { resources: [], rootPath: '/admin', auth: { isSecure: process.env.NODE_ENV === 'production', }, registerInert: true, } await server.register({ plugin: AdminJSHapi, options: adminOptions, }) await server.start(); console.log(`AdminJS available at ${server.info.uri}${adminOptions.rootPath}`); } start() ``` -------------------------------- ### Simple Hapi Setup - Javascript Source: https://docs.adminjs.co/installation/plugins/hapi Basic setup for the AdminJS Hapi plugin in a Javascript Hapi application. Ensure AdminJS packages are installed. ```javascript import AdminJSHapi from '@adminjs/hapi' import Hapi from '@hapi/hapi' const PORT = 3000 const start = async () => { const server = Hapi.server({ port: PORT }) const adminOptions: ExtendedAdminJSOptions = { resources: [], rootPath: '/admin', auth: { isSecure: process.env.NODE_ENV === 'production', }, registerInert: true, } await server.register({ plugin: AdminJSHapi, options: adminOptions, }) await server.start(); console.log(`AdminJS available at ${server.info.uri}${adminOptions.rootPath}`); } start() ``` -------------------------------- ### Install Upload Feature Source: https://docs.adminjs.co/basics/features/upload Run this command to install the upload feature package. ```shell $ yarn add @adminjs/upload ``` -------------------------------- ### Setup AdminJS with Express (JavaScript) Source: https://docs.adminjs.co/installation/plugins/express Configure and start an AdminJS panel within an Express.js application using JavaScript. ```javascript import AdminJS from 'adminjs' import AdminJSExpress from '@adminjs/express' import express from 'express' const PORT = 3000 const start = async () => { const app = express() const admin = new AdminJS({}) const adminRouter = AdminJSExpress.buildRouter(admin) app.use(admin.options.rootPath, adminRouter) app.listen(PORT, () => { console.log(`AdminJS started on http://localhost:${PORT}${admin.options.rootPath}`) }) } start() ``` -------------------------------- ### Simple Fastify Integration (JavaScript) Source: https://docs.adminjs.co/installation/plugins/fastify Basic setup for integrating AdminJS with a Fastify application using JavaScript. This example initializes AdminJS and builds the router for the AdminJS panel. ```javascript import AdminJSFastify from '@adminjs/fastify' import AdminJS from 'adminjs' import Fastify from 'fastify' const PORT = 3000 const start = async () => { const app = Fastify() const admin = new AdminJS({ databases: [], rootPath: '/admin' }) await AdminJSFastify.buildRouter( admin, app, ) app.listen({ port: PORT }, (err, addr) => { if (err) { console.error(err) } else { console.log(`AdminJS started on http://localhost:${PORT}${admin.options.rootPath}`) } }) } start() ``` -------------------------------- ### Start NestJS Application Source: https://docs.adminjs.co/installation/plugins/nest Command to start the NestJS application after configuration. ```bash nest start ``` -------------------------------- ### Install MikroORM Adapter Source: https://docs.adminjs.co/installation/adapters/mikroorm Install the AdminJS MikroORM adapter using npm or yarn. ```bash npm install @adminjs/mikroorm # or yarn add @adminjs/mikroorm ``` -------------------------------- ### Example Theme Credentials Source: https://docs.adminjs.co/basics/themes An example of the credentials format for accessing the demo application with a specific theme, in this case, the 'dark' theme. ```text Email: dark@example.com Password: password ``` -------------------------------- ### Install @adminjs/logger Source: https://docs.adminjs.co/basics/features/logger Install the logger plugin using yarn. ```shell $ yarn add @adminjs/logger ``` -------------------------------- ### Install Fastify Session Dependencies Source: https://docs.adminjs.co/installation/plugins/fastify Install the necessary packages for session management with Fastify. ```bash $ yarn add @fastify/session connect-pg-simple ``` -------------------------------- ### Basic Express Setup with AdminJS Source: https://docs.adminjs.co/installation/plugins/express This snippet shows a basic setup for an Express application with AdminJS integrated. It includes initializing AdminJS and setting up the Express router. ```javascript const AdminJS = require('adminjs') const AdminJSExpress = require('@adminjs/express') const express = require('express') const app = express() const adminJs = new AdminJS({ rootPath: '/admin', }) const router = AdminJSExpress.buildRouter(adminJs) app.use(adminJs.options.rootPath, router) app.listen(8080, () => console.log('Admin Server running on http://localhost:8080/admin')) ``` -------------------------------- ### AdminJS with Custom Database Adapter Source: https://docs.adminjs.co/installation/plugins/express This example illustrates how to use AdminJS with a custom database adapter, such as Mongoose. It requires installing the specific adapter package. ```javascript const AdminJS = require('adminjs') const AdminJSExpress = require('@adminjs/express') const express = require('express') const mongoose = require('mongoose') const AdminJS Mongoose = require('@adminjs/mongoose') AdminJS.registerAdapter(AdminJS Mongoose) const app = express() const adminJs = new AdminJS({ rootPath: '/admin', // ... other AdminJS options }) const router = AdminJSExpress.buildRouter(adminJs) app.use(adminJs.options.rootPath, router) app.listen(8080, () => console.log('Admin Server running on http://localhost:8080/admin')) ``` -------------------------------- ### Install @adminjs/firebase-auth Source: https://docs.adminjs.co/basics/authentication/firebaseauthprovider Install the Firebase authentication provider package using yarn. ```bash yarn add @adminjs/firebase-auth ``` -------------------------------- ### Query Documentation with HTTP GET Source: https://docs.adminjs.co/tutorials/adding-role-based-access-control Perform an HTTP GET request on a documentation URL with the `ask` query parameter to get specific answers and relevant excerpts. The question should be self-contained and in natural language. ```http GET https://docs.adminjs.co/tutorials/adding-role-based-access-control.md?ask= ``` -------------------------------- ### Install Dependencies for Express Authentication Source: https://docs.adminjs.co/installation/plugins/express Install the necessary packages for session management with PostgreSQL. This includes `connect-pg-simple` for session storage. ```bash $ yarn add connect-pg-simple ``` -------------------------------- ### Install ajv-formats Source: https://docs.adminjs.co/installation/adapters/objection Install this library to enable format validation for your JSON schemas. ```bash $ yarn add ajv-formats ``` -------------------------------- ### Install Themes Package Source: https://docs.adminjs.co/basics/themes Install the AdminJS themes package using yarn. ```bash $ yarn add @adminjs/themes ``` -------------------------------- ### Install Fastify Peer Dependencies Source: https://docs.adminjs.co/installation/plugins/fastify Ensure you have Fastify and its required peer dependencies installed. ```bash yarn add fastify tslib ``` -------------------------------- ### Install and Configure Session and Lucid Source: https://docs.adminjs.co/installation/plugins/adonis Install the necessary AdonisJS packages for session management and Lucid ORM, then configure them using the ACE CLI. ```bash $ npm install @adonisjs/session @adonisjs/lucid $ node ace configure @adonisjs/session $ node ace configure @adonisjs/lucid ``` -------------------------------- ### Install AdminJS Hapi Plugin Source: https://docs.adminjs.co/installation/plugins/hapi Install the necessary AdminJS packages for Hapi integration. ```bash yarn add adminjs @adminjs/hapi ``` -------------------------------- ### Ask a Question via GET Request Source: https://docs.adminjs.co/Theme.html Use this endpoint to perform an HTTP GET request on the documentation index with the 'ask' parameter to get a direct answer to your question. ```http GET https://docs.adminjs.co/readme.md?ask= ``` -------------------------------- ### Install AdminJS Database Adapters Source: https://docs.adminjs.co/installation/getting-started Installs adapters to connect AdminJS with your database ORM/ODM. ```bash yarn add @adminjs/typeorm # for TypeORM ``` ```bash yarn add @adminjs/sequelize # for Sequelize ``` ```bash yarn add @adminjs/mongoose # for Mongoose ``` ```bash yarn add @adminjs/prisma # for Prisma ``` ```bash yarn add @adminjs/mikroorm # for MikroORM ``` ```bash yarn add @adminjs/objection # for Objection ``` ```bash yarn add @adminjs/sql # for raw SQL, currently supports only Postgres ``` -------------------------------- ### Install AdminJS and Express Plugin Source: https://docs.adminjs.co/installation/plugins/express Install the necessary AdminJS packages, including the Express plugin, using yarn. ```bash $ yarn add adminjs @adminjs/express ``` -------------------------------- ### Install AdminJS Fastify Plugin Source: https://docs.adminjs.co/installation/plugins/fastify Install the necessary AdminJS packages for Fastify integration. ```bash yarn add adminjs @adminjs/fastify ``` -------------------------------- ### Install AdminJS and NestJS Plugin Source: https://docs.adminjs.co/installation/plugins/nest Install the necessary AdminJS and NestJS plugin packages using Yarn. ```bash yarn add adminjs @adminjs/nestjs ``` -------------------------------- ### Install Dependencies for Express Authentication (TypeScript) Source: https://docs.adminjs.co/installation/plugins/express Install the necessary packages for session management with PostgreSQL, including type definitions for TypeScript. This includes `connect-pg-simple` for session storage. ```bash $ yarn add connect-pg-simple $ yarn add -D @types/connect-pg-simple @types/express-session @types/express ``` -------------------------------- ### Install @adminjs/passwords Source: https://docs.adminjs.co/basics/features/password Install the password feature package using yarn. ```shell yarn add @adminjs/passwords ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.adminjs.co/faq/resource Perform an HTTP GET request on a documentation URL with the 'ask' query parameter to ask a question. The response will include a direct answer and relevant excerpts. ```http GET https://docs.adminjs.co/faq/resource.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.adminjs.co/basics/features/logger Perform an HTTP GET request on a documentation page URL with the `ask` query parameter to get specific information. The question should be clear and self-contained. ```http GET https://docs.adminjs.co/basics/features/logger.md?ask= ``` -------------------------------- ### Install AdminJS Framework Plugins Source: https://docs.adminjs.co/installation/getting-started Installs plugins to integrate AdminJS with your chosen web framework. ```bash yarn add @adminjs/express # for Express server ``` ```bash yarn add @adminjs/nestjs # for Nest server ``` ```bash yarn add @adminjs/hapi # for Hapi server ``` ```bash yarn add @adminjs/koa # for Koa server ``` ```bash yarn add @adminjs/fastify # for Fastify server ``` -------------------------------- ### Install Hapi Peer Dependencies Source: https://docs.adminjs.co/installation/plugins/hapi Ensure you have the required peer dependencies for the Hapi plugin installed. ```bash yarn add @hapi/hapi @hapi/boom @hapi/cookie @hapi/inert ``` -------------------------------- ### Install Express Types for TypeScript Source: https://docs.adminjs.co/installation/plugins/express If you are using TypeScript, install the necessary types for Express. ```bash $ yarn add -D @types/express ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.adminjs.co/basics/api/bulk-delete Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific and in natural language. ```http GET https://docs.adminjs.co/basics/api/bulk-delete.md?ask= ``` -------------------------------- ### Install Express and Peer Dependencies Source: https://docs.adminjs.co/installation/plugins/express Ensure Express.js and its required peer dependencies are installed for the AdminJS integration. ```bash $ yarn add express tslib express-formidable express-session ``` -------------------------------- ### Querying Documentation with GET Request Source: https://docs.adminjs.co/basics/api/delete To get additional information not directly present on the page, perform an HTTP GET request to the current page URL with the `ask` query parameter. The question should be specific and self-contained. ```http GET https://docs.adminjs.co/basics/api/delete.md?ask= ``` -------------------------------- ### Install AdminJS CLI Globally Source: https://docs.adminjs.co/installation/getting-started Installs the AdminJS command-line interface globally for creating new AdminJS applications. ```bash npm i -g @adminjs/cli ``` ```bash yarn global add @adminjs/cli ``` -------------------------------- ### Install AdminJS Matrix Plugin Source: https://docs.adminjs.co/installation/plugins/matrix Install the @adminjs/matrix package using npm. This command should be run in your project's root directory. ```bash npm install @adminjs/matrix ``` -------------------------------- ### Install @adminjs/relations Source: https://docs.adminjs.co/basics/features/relations Install the relations addon using yarn. This is a premium feature requiring a license key. ```bash yarn add @adminjs/relations ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.adminjs.co/basics/api Perform an HTTP GET request to the current page URL with the `ask` query parameter to get dynamic information. The question should be specific and self-contained. ```http GET https://docs.adminjs.co/basics/api.md?ask= ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.adminjs.co/basics/api/new To get more information not present on the current page, make an HTTP GET request to the page URL with an 'ask' query parameter containing your question. The response will include a direct answer and relevant documentation excerpts. ```http GET https://docs.adminjs.co/basics/api/new.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.adminjs.co/installation/plugins To get more information not present on the current page, make a GET request to the page URL with an 'ask' query parameter containing your question. ```http GET https://docs.adminjs.co/installation/plugins.md?ask= ``` -------------------------------- ### Install Custom Components Library Source: https://docs.adminjs.co/tutorials/custom-components-library Install the custom components library using yarn. This command adds the necessary package to your project dependencies. ```shell yarn add @adminjs/custom-components ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.adminjs.co/basics/api/list To get additional information not explicitly present on a page, perform an HTTP GET request with an 'ask' query parameter. The question should be specific and self-contained. ```http GET https://docs.adminjs.co/basics/api/list.md?ask= ``` -------------------------------- ### Query Documentation with `ask` Parameter Source: https://docs.adminjs.co/tutorials/custom-components-library To get more information not present on the page, perform an HTTP GET request with the `ask` query parameter. The question should be specific and in natural language. ```http GET https://docs.adminjs.co/tutorials/custom-components-library.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.adminjs.co/api-reference Perform an HTTP GET request on the current page URL with the `ask` query parameter to get answers to specific questions. The question should be in natural language and self-contained. Use this when the answer is not explicit, for clarification, or to retrieve related sections. ```http GET https://docs.adminjs.co/api-reference.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.adminjs.co/tutorials/content-management-system To get additional information not present on the page, perform an HTTP GET request to the current page URL with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://docs.adminjs.co/tutorials/content-management-system.md?ask= ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.adminjs.co/basics/features/import-and-export To get specific information not directly on the page, make a GET request to the documentation URL with the 'ask' query parameter followed by your question. ```http GET https://docs.adminjs.co/basics/features/import-and-export.md?ask= ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.adminjs.co/installation/plugins/community-plugins To get specific information not directly on the page, make an HTTP GET request to the current URL with the 'ask' query parameter. The question should be clear and self-contained. ```http GET https://docs.adminjs.co/installation/plugins/community-plugins.md?ask= ``` -------------------------------- ### Local Filesystem Setup Source: https://docs.adminjs.co/basics/features/upload Configure the upload feature for local filesystem storage. Ensure the 'bucket' folder is accessible via a web browser. ```javascript import * as url from 'url' // other imports const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) app.use(express.static(path.join(__dirname, '../public'))); ``` ```typescript import uploadFeature from '@adminjs/upload'; import { File } from './models/file.js'; import componentLoader from './component-loader.js'; const localProvider = { bucket: 'public/files', opts: { baseUrl: '/files', }, }; export const files = { resource: File, options: { properties: { s3Key: { type: 'string', }, bucket: { type: 'string', }, mime: { type: 'string', }, comment: { type: 'textarea', isSortable: false, }, }, }, features: [ uploadFeature({ componentLoader, provider: { local: localProvider }, validation: { mimeTypes: ['image/png', 'application/pdf', 'audio/mpeg'] }, }), ], }; ``` -------------------------------- ### AdminJS API Search Example Source: https://docs.adminjs.co/basics/api/search This example demonstrates a GET request to the AdminJS API's search endpoint for 'categories' resource, searching for 'Games'. It shows the expected JSON response structure containing records, their parameters, and available actions. ```json { "records":[ { "params":{ "id":2, "name":"Games", "createdAt":"2023-01-30T13:01:39.597Z", "updatedAt":"2023-01-30T13:01:39.597Z" }, "populated":{ }, "baseError":null, "errors":{ }, "id":2, "title":"Games", "recordActions":[ { "name":"show", "actionType":"record", "icon":"Screen", "label":"Show", "resourceId":"categories", "guard":"", "showFilter":false, "showResourceActions":true, "showInDrawer":false, "hideActionHeader":false, "containerWidth":1, "layout":null, "variant":"default", "parent":null, "hasHandler":true, "custom":{ } }, { "name":"edit", "actionType":"record", "icon":"Edit", "label":"Edit", "resourceId":"categories", "guard":"", "showFilter":false, "showResourceActions":true, "showInDrawer":false, "hideActionHeader":false, "containerWidth":1, "layout":null, "variant":"default", "parent":null, "hasHandler":true, "custom":{ } }, { "name":"delete", "actionType":"record", "icon":"TrashCan", "label":"Delete", "resourceId":"categories", "guard":"Do you really want to remove this item?", "showFilter":false, "showResourceActions":true, "component":false, "showInDrawer":false, "hideActionHeader":false, "containerWidth":1, "layout":null, "variant":"danger", "parent":null, "hasHandler":true, "custom":{ } } ], "bulkActions":[ { "name":"bulkDelete", "actionType":"bulk", "icon":"Delete", "label":"Delete all", "resourceId":"categories", "guard":"", "showFilter":false, "showResourceActions":true, "showInDrawer":true, "hideActionHeader":false, "containerWidth":"500px", "layout":null, "variant":"danger", "parent":null, "hasHandler":true, "custom":{ } } ] } ] } ``` -------------------------------- ### Add FirebaseAuthProvider to AdminJS Authentication Source: https://docs.adminjs.co/basics/authentication/firebaseauthprovider Integrate the configured FirebaseAuthProvider into your AdminJS authentication setup. This example shows integration with an Express router. ```typescript // ... const router = buildAuthenticatedRouter( admin, { cookiePassword: 'test', provider: authProvider, }, null, { secret: 'test', resave: false, saveUninitialized: true, } ); ``` -------------------------------- ### Querying Documentation with 'ask' Parameter Source: https://docs.adminjs.co/basics/api/edit This example demonstrates how to dynamically query the AdminJS documentation for additional information not explicitly present on the page. Use the `ask` query parameter with a specific question. ```http GET https://docs.adminjs.co/basics/api/edit.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.adminjs.co/basics/features Shows how to query the documentation dynamically using an HTTP GET request with the `ask` query parameter. This is useful for retrieving specific information not explicitly present on the page. ```http GET https://docs.adminjs.co/basics/features.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.adminjs.co/installation/plugins/hapi Use this method to ask questions about the documentation. The question should be specific and self-contained. The response will include a direct answer and relevant excerpts. ```http GET https://docs.adminjs.co/installation/plugins/hapi.md?ask= ``` -------------------------------- ### Configure AdminJS with SQL Resources Source: https://docs.adminjs.co/installation/adapters/sql Create an AdminJS instance, specifying resources by referencing tables from the initialized database adapter. Loading the entire database is not recommended. ```typescript const admin = new AdminJS({ resources: [ { resource: db.table('users'), options: {}, }, ], // databases: [db], <- not recommended }); ``` -------------------------------- ### Install TypeScript Types for Koa Source: https://docs.adminjs.co/installation/plugins/koa Install TypeScript types for Koa if you are using TypeScript. ```bash $ yarn add -D @types/koa ``` -------------------------------- ### Install Koa Peer Dependencies Source: https://docs.adminjs.co/installation/plugins/koa Install Koa and its required peer dependencies for AdminJS. ```bash $ yarn add koa @koa/router koa2-formidable ``` -------------------------------- ### Install AdminJS Koa Package Source: https://docs.adminjs.co/installation/plugins/koa Install the necessary AdminJS packages for Koa integration. ```bash $ yarn add adminjs @adminjs/koa ``` -------------------------------- ### Register and Initialize SQL Adapter Source: https://docs.adminjs.co/installation/adapters/sql Register the SQL adapter with AdminJS and initialize it by providing database dialect and connection options. The connection options are based on Knex.js configuration. ```typescript AdminJS.registerAdapter({ Database, Resource, }) // ... const db = await new Adapter('postgresql', { connectionString: '', database: '', }).init() ``` -------------------------------- ### Install AdminJS Core Package Source: https://docs.adminjs.co/installation/plugins/adonis Install the main AdminJS package into your AdonisJS project. ```bash $ npm install adminjs ``` -------------------------------- ### Install Leaflet Feature Source: https://docs.adminjs.co/basics/features/leaflet-maps Install the Leaflet feature package using yarn or npm. ```bash yarn add @adminjs/leaflet # or: npm install @adminjs/leaflet ``` -------------------------------- ### Implement Custom Authentication Provider Source: https://docs.adminjs.co/installation/plugins/matrix Use this example to create a custom authentication provider. It handles user authentication using email and password and generates a Matrix token. Replace placeholder logic with your actual database and password verification functions. ```typescript import { DefaultAuthProvider } from 'adminjs'; import componentLoader from './component-loader.js'; const provider = new DefaultAuthProvider({ componentLoader, authenticate: async ({ email, password }) => { // Example implementation - replace with your own authentication logic const user = await db.users.findOne({ email }); if (user && await verifyPassword(user.password, password)) { // Get or generate a Matrix token for this user const matrixToken = await getMatrixTokenForUser(user); return { email: user.email, _auth: { matrixAccessToken: matrixToken } }; } return null; } }); export default provider; ``` -------------------------------- ### Perform HTTP GET Request to Query Documentation Source: https://docs.adminjs.co/basics/resource Use this method to ask specific questions about the documentation. The response includes direct answers and relevant excerpts. ```http GET https://docs.adminjs.co/basics/resource.md?ask= ``` -------------------------------- ### Install AdminJS Core Package Source: https://docs.adminjs.co/installation/getting-started Installs the main AdminJS package, which is required for any AdminJS application. ```bash yarn add adminjs ``` -------------------------------- ### Create AdonisJS App Source: https://docs.adminjs.co/installation/plugins/adonis Use the AdonisJS CLI to create a new application. This command initializes a slim version of the framework. ```bash $ npm init adonisjs@latest -- -K=slim ``` -------------------------------- ### Matrix User Authentication Setup Source: https://docs.adminjs.co/basics/authentication/matrixauthprovider Configure the MatrixAuthProvider by providing the Matrix server base URL and a component loader. Ensure the MATRIX_BASE_URL environment variable is set. ```typescript import { MatrixAuthProvider } from '@adminjs/matrix'; import componentLoader from './component-loader.js'; const provider = new MatrixAuthProvider({ baseUrl: process.env.MATRIX_BASE_URL, componentLoader, }); export default provider; ``` -------------------------------- ### Create New AdminJS Application Source: https://docs.adminjs.co/installation/getting-started Use the AdminJS CLI to quickly scaffold a new AdminJS application. ```bash adminjs create ``` -------------------------------- ### Raw Data Variable Example Source: https://docs.adminjs.co/faq/charts An example of the raw data structure fetched from the database before reformatting for charts. ```typescript [ { params: { id: 2104, title: 'Arrival', year: 2018, score: 84 }, baseError: null, // ... }, { params: { id: 2226, title: 'Harry Potter and the Goblet of Fire', year: 2018, score: 96 }, baseError: null, // ... }, // ... ] ``` -------------------------------- ### Install and Configure AdminJS Adonis Integration Source: https://docs.adminjs.co/installation/plugins/adonis Install the `@adminjs/adonis` package and configure it for your application using the ACE CLI. ```bash $ npm install @adminjs/adonis $ node ace configure @adminjs/adonis ``` -------------------------------- ### Install @adminjs/import-export Package Source: https://docs.adminjs.co/basics/features/import-and-export Install the @adminjs/import-export package using yarn to enable the import-export functionality in your AdminJS project. ```shell $ yarn add @adminjs/import-export ``` -------------------------------- ### Initialize MikroORM Adapter Source: https://docs.adminjs.co/installation/adapters/mikroorm Initialize the MikroORM adapter with your MikroORM configuration and entities. ```typescript import AdminJS from 'adminjs'; import { MikroORM } from '@mikro-orm/core'; import { MikroORMAdapter } from '@adminjs/mikroorm'; // Assuming you have your MikroORM instance initialized const orm = await MikroORM.init({ entities: ['./dist/entities'], dbName: 'my-db', type: 'postgresql', }); AdminJS.registerAdapter(MikroORMAdapter); const admin = new AdminJS({ // ... AdminJS configuration resources: [ { resource: orm.em.getRepository('User'), // Replace 'User' with your entity name options: { // Optional: configure resource options // ... }, }, // ... other resources ], }); ``` -------------------------------- ### Install Fastify Session TypeScript Dependencies Source: https://docs.adminjs.co/installation/plugins/fastify Install the necessary packages for session management with Fastify, including TypeScript types. ```bash $ yarn add @fastify/session connect-pg-simple $ yarn add -D @types/connect-pg-simple ```