### Install Open Signup Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/open-signup Command to install the Open Signup plugin dependency via pnpm. ```bash pnpm install @adminforth/open-signup --save ``` -------------------------------- ### Install Local Storage Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the local storage adapter for storing files directly on the server's filesystem. This is suitable for development and small-scale setups but not recommended for production. ```bash pnpm i @adminforth/storage-adapter-local ``` -------------------------------- ### Install Adminforth Quick Filters Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/quick-filters This command installs the @adminforth/quick-filters plugin using pnpm. Ensure you have Node.js and pnpm installed. ```bash pnpm i @adminforth/quick-filters ``` -------------------------------- ### Install Text Complete Plugin Dependencies Source: https://adminforth.dev/docs/tutorial/Plugins/text-complete Commands to install the core text completion plugin and the OpenAI adapter via pnpm. ```bash pnpm i @adminforth/text-complete --save pnpm i @adminforth/completion-adapter-open-ai-chat-gpt --save ``` -------------------------------- ### Install OpenAI Completion Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the OpenAI completion adapter, which integrates AdminForth with OpenAI's ChatGPT models for AI-powered text completion and chat functionalities. ```bash pnpm i @adminforth/completion-adapter-open-ai-chat-gpt ``` -------------------------------- ### Install AdminForth Background Jobs Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/background-jobs Install the necessary package via pnpm to start using background job functionality in your AdminForth project. ```bash pnpm i @adminforth/background-jobs ``` -------------------------------- ### Install and Import 2FA Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/TwoFactorsAuth Commands and code to install the dependency via pnpm and import the plugin into your project. ```bash pnpm i @adminforth/two-factors-auth --save ``` ```typescript import TwoFactorsAuthPlugin from '@adminforth/two-factors-auth'; ``` -------------------------------- ### Initialize Frontend Dependencies Source: https://adminforth.dev/docs/tutorial/Advanced/plugin-development Commands to initialize a package.json and install the vue-suggestion-input dependency for the plugin's frontend component. ```bash cd af-plugin-chatgpt/custom pnpm init -y pnpm i vue-suggestion-input -D ``` -------------------------------- ### Install Local Storage Adapter for AdminForth Source: https://adminforth.dev/docs/tutorial/Plugins/05-0-upload This command installs the local storage adapter package for AdminForth. This adapter allows files to be saved directly to the server's filesystem. ```bash pnpm i @adminforth/storage-adapter-local --save ``` -------------------------------- ### Install Email Password Reset Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/email-password-reset Install the core plugin and the required AWS SES adapter using pnpm. ```bash pnpm install @adminforth/email-password-reset --save pnpm install @adminforth/email-adapter-aws-ses --save ``` -------------------------------- ### Install Universal Search Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/universal-filters Installs the Universal Search plugin using pnpm. This is the first step to integrating the search functionality into your AdminForth project. ```bash pnpm i @adminforth/universal-search --save ``` -------------------------------- ### Install and Use Node Version Manager Source: https://adminforth.dev/docs/tutorial/gettingStarted Installs Node.js version 20, sets it as the default, and switches to it using NVM. This ensures the correct Node.js version for AdminForth. ```bash nvm install 20 nvm alias default 20 nvm use 20 ``` -------------------------------- ### Install AdminForth OAuth Plugin and Adapters Source: https://adminforth.dev/docs/tutorial/Plugins/oauth Installs the core AdminForth OAuth plugin and specific adapters for OAuth providers like Google. These are essential for enabling OAuth authentication. ```bash pnpm install @adminforth/oauth --save pnpm install @adminforth/google-oauth-adapter --save # for Google OAuth ``` -------------------------------- ### Install Login Captcha Plugin and Adapter Source: https://adminforth.dev/docs/tutorial/Plugins/login-captcha Commands to install the core captcha plugin and the specific Cloudflare adapter dependency using pnpm. ```bash pnpm i @adminforth/login-captcha pnpm i @adminforth/login-captcha-adapter-cloudflare ``` -------------------------------- ### Install reCaptcha Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Provides the command to install the reCaptcha Adapter, used for integrating Google's reCAPTCHA service into the login screen. ```bash pnpm i @adminforth/login-captcha-adapter-recaptcha ``` -------------------------------- ### Install AdminForth S3 Storage Adapter Source: https://adminforth.dev/docs/tutorial/Plugins/05-0-upload Command to install the required storage adapter package for Amazon S3 integration. ```bash pnpm i @adminforth/storage-adapter-amazon-s3 --save ``` -------------------------------- ### Install @adminforth/clone-row Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/clone-row Installs the clone-row plugin using pnpm. This is the first step to enable the record cloning functionality. ```bash pnpm install @adminforth/clone-row --save ``` -------------------------------- ### Initialize AdminForth Project Source: https://adminforth.dev/docs/tutorial/hello-world Commands to create the project directory, initialize npm, install necessary dependencies, and generate a TypeScript configuration file. ```bash mkdir af-hello cd af-hello npm init -y npm i adminforth express @dotenvx/dotenvx @types/express typescript tsx @types/node -D npx --yes tsc --init --module NodeNext --target ESNext ``` -------------------------------- ### Install Many2Many Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/many2many Command to install the @adminforth/many2many package via pnpm. ```bash pnpm i @adminforth/many2many ``` -------------------------------- ### Install GitHub OAuth Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the GitHub OAuth adapter, allowing users to authenticate using their GitHub credentials. This is particularly useful for developer tools and open-source projects. ```bash pnpm i @adminforth/github-oauth-adapter ``` -------------------------------- ### Install ForeignInlineShow Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/ForeignInlineShow Install the required package using pnpm to enable the foreign inline show functionality in your AdminForth project. ```bash pnpm i @adminforth/foreign-inline-show --save ``` -------------------------------- ### Database Migration and Package Installation Source: https://adminforth.dev/docs/tutorial/Plugins/RichEditor Commands to generate and apply database migrations for the new image schema, and to install the required AdminForth upload and local storage adapter packages. These steps are crucial for setting up the backend for image handling. ```bash pnpm makemigration --name add_description_image ; pnpm migrate:local ``` ```bash pnpm i @adminforth/upload --save pnpm i @adminforth/storage-adapter-local --save ``` -------------------------------- ### Run AdminForth Development Server Source: https://adminforth.dev/docs/tutorial/gettingStarted Starts the AdminForth development server, making the application accessible at http://localhost:3500. ```bash pnpm start ``` -------------------------------- ### Install Google Gemini Completion Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Google Gemini completion adapter, enabling AdminForth to utilize Google Gemini models for AI-powered text completion and conversational AI features. ```bash pnpm i @adminforth/completion-adapter-google-gemini ``` -------------------------------- ### Install Microsoft OAuth Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Microsoft OAuth adapter, supporting authentication via Microsoft accounts, including Azure AD, Office365, and Outlook.com. ```bash pnpm i @adminforth/microsoft-oauth-adapter ``` -------------------------------- ### Install Twitch OAuth Adapter Source: https://adminforth.dev/docs/tutorial/Plugins/oauth Installs the Twitch OAuth adapter using pnpm. This is the first step to integrate Twitch authentication into your Adminforth application. ```bash pnpm install @adminforth/twitch-oauth-adapter --save ``` -------------------------------- ### Install Google OAuth Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Google OAuth adapter, enabling user authentication through Google accounts. This is commonly used for integrating Google sign-in into applications. ```bash pnpm i @adminforth/google-oauth-adapter ``` -------------------------------- ### Install Keycloak OAuth Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Keycloak OAuth adapter to connect AdminForth with a Keycloak identity provider, facilitating enterprise-grade Single Sign-On (SSO). ```bash pnpm i @adminforth/keycloak-oauth-adapter ``` -------------------------------- ### Install OpenAI Image Generation Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the OpenAI image generation adapter, enabling the use of models like DALLΒ·E for creating images from text prompts. It leverages powerful OpenAI models for image synthesis. ```bash pnpm i @adminforth/image-generation-adapter-openai ``` -------------------------------- ### Install OpenAI Vision Adapter for Image Analysis Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Provides the command to install the OpenAI Vision Adapter, which enables AI-powered image analysis capabilities within AdminForth. This adapter can describe image content, extract text, and identify objects. ```bash pnpm install @adminforth/image-vision-adapter-openai --save ``` -------------------------------- ### Install Audit Log Plugin with PNPM Source: https://adminforth.dev/docs/tutorial/Plugins/AuditLog Installs the AuditLog plugin using the PNPM package manager. This is the first step to enable logging capabilities. ```bash pnpm i @adminforth/audit-log --save ``` -------------------------------- ### Install Cloudflare Captcha Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Provides the command to install the Cloudflare Captcha Adapter, used for integrating Cloudflare's CAPTCHA service into the login screen. ```bash pnpm i @adminforth/login-captcha-adapter-cloudflare ``` -------------------------------- ### Install Bulk AI Flow Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/bulk-ai-flow Installs the Bulk AI Flow plugin and the OpenAI image vision adapter using pnpm. These are necessary dependencies for the plugin's functionality. ```bash pnpm install @adminforth/bulk-ai-flow --save ``` ```bash pnpm install @adminforth/image-vision-adapter-openai --save ``` -------------------------------- ### Install Inline Create Plugin with pnpm Source: https://adminforth.dev/docs/tutorial/Plugins/inline-create This command installs the Inline Create plugin using the pnpm package manager. It is a direct dependency for enabling the inline create functionality. ```bash pnpm install @adminforth/inline-create --save ``` -------------------------------- ### Install Facebook OAuth Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Facebook OAuth adapter, which enables users to log in using their Facebook accounts. This is a common choice for social media integrations. ```bash pnpm i @adminforth/facebook-oauth-adapter ``` -------------------------------- ### Install AdminForth i18n and OpenAI Completion Adapter Source: https://adminforth.dev/docs/tutorial/Plugins/i18n Installs the necessary AdminForth i18n plugin and the OpenAI completion adapter for automated translations. These packages are essential for enabling multilingual support and AI-powered translation features. ```bash pnpm install @adminforth/i18n --save pnpm install @adminforth/completion-adapter-open-ai-chat-gpt --save ``` -------------------------------- ### Install and Link AdminForth Plugin Locally Source: https://adminforth.dev/docs/tutorial/Advanced/plugin-development Commands to link a local plugin directory to an AdminForth project for testing purposes. ```bash cd af-plugin-chatgpt pnpm link cd ../your-adminforth-project pnpm link af-plugin-chatgpt ``` -------------------------------- ### Install RAM Key-Value Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Command to install the RAM Key-Value Adapter, a simple in-memory storage solution. It's suitable for single-process applications where data does not need to persist across restarts or be shared between processes. ```bash pnpm i @adminforth/key-value-adapter-ram ``` -------------------------------- ### CLI Command: version Source: https://adminforth.dev/docs/tutorial/CLICommands Displays the current version of the installed AdminForth CLI. ```APIDOC ## CLI COMMAND: version ### Description Displays the version number of the currently installed AdminForth CLI for compatibility checking. ### Usage `adminforth version` or `adminforth -v` ### Output Example ``` AdminForth CLI version: 1.6.2 ``` ``` -------------------------------- ### Register ChatGptPlugin in AdminForth Source: https://adminforth.dev/docs/tutorial/Advanced/plugin-development Example of importing and configuring the ChatGptPlugin within the AdminForth resource configuration. ```typescript import ChatGptPlugin from 'af-plugin-chatgpt'; { resourceId: 'aparts', plugins: [ new ChatGptPlugin({ openAiApiKey: process.env.OPENAI_API_KEY as string, fieldName: 'title', }), new ChatGptPlugin({ openAiApiKey: process.env.OPENAI_API_KEY as string, fieldName: 'description', }), ] } ``` -------------------------------- ### Integrate Alerts and Confirmations in Vue Components Source: https://adminforth.dev/docs/tutorial/Customization/alert Example of a custom Vue component implementing alert and confirm methods within a script setup block. ```vue ``` -------------------------------- ### Initialize AdminForth Configuration Source: https://adminforth.dev/docs/tutorial/hello-world This snippet shows the basic setup of an AdminForth instance, including authentication, UI customization, data source connection, and resource definitions for users and posts. ```typescript import express from 'express'; import AdminForth, { AdminForthDataTypes, Filters, logger } from 'adminforth'; import type { AdminForthResourceInput, AdminForthResource, AdminUser } from 'adminforth'; export const admin = new AdminForth({ baseUrl: '', auth: { usersResourceId: 'adminuser', usernameField: 'email', passwordHashField: 'passwordHash', }, customization: { brandName: 'My Admin', datesFormat: 'D MMM YY', timeFormat: 'HH:mm:ss', emptyFieldPlaceholder: '-', }, dataSources: [{ id: 'maindb', url: `sqlite://${process.env.DATABASE_FILE}`, }], resources: [ { dataSource: 'maindb', table: 'adminuser', resourceId: 'adminuser', label: 'Users', recordLabel: (r: any) => `πŸ‘€ ${r.email}`, columns: [ { name: 'id', primaryKey: true, fillOnCreate: () => Math.random().toString(36).substring(7), showIn: { edit: false, create: false } }, { name: 'email', required: true, isUnique: true, enforceLowerCase: true, validation: [AdminForth.Utils.EMAIL_VALIDATOR] }, { name: 'createdAt', type: AdminForthDataTypes.DATETIME, showIn: { edit: false, create: false }, fillOnCreate: () => (new Date()).toISOString() }, { name: 'role', enum: [{ value: 'superadmin', label: 'Super Admin' }, { value: 'user', label: 'User' }] }, { name: 'password', virtual: true, required: { create: true }, editingNote: { edit: 'Leave empty to keep password unchanged' }, minLength: 8, type: AdminForthDataTypes.STRING, showIn: { show: false, list: false, filter: false }, masked: true }, { name: 'passwordHash', backendOnly: true, showIn: { all: false } } ], hooks: { create: { beforeSave: async ({ record, adminUser, resource }: { record: any, adminUser: AdminUser, resource: AdminForthResource }) => { record.password_hash = await AdminForth.Utils.generatePasswordHash(record.password); return { ok: true }; } }, edit: { beforeSave: async ({ oldRecord, updates, adminUser, resource }: { oldRecord: any, updates: any, adminUser: AdminUser, resource: AdminForthResource }) => { logger.info('Updating user', updates); if (oldRecord.id === adminUser.dbUser.id && updates.role) { return { ok: false, error: 'You cannot change your own role' }; } if (updates.password) { updates.password_hash = await AdminForth.Utils.generatePasswordHash(updates.password); } return { ok: true } } } } }, { table: 'post', resourceId: 'posts', dataSource: 'maindb', label: 'Posts', recordLabel: (r: any) => `πŸ“ ${r.title}`, columns: [ { name: 'id', primaryKey: true, fillOnCreate: () => Math.random().toString(36).substring(7), showIn: { edit: false, create: false } }, { name: 'title', type: AdminForthDataTypes.STRING, required: true, showIn: { all: true }, maxLength: 255, minLength: 3 }, { name: 'content', showIn: { all: true } }, { name: 'createdAt', showIn: { edit: false, create: false }, fillOnCreate: () => (new Date()).toISOString() }, { name: 'published', required: true }, { name: 'authorId', foreignResource: { resourceId: 'adminuser' }, showIn: { edit: false, create: false }, fillOnCreate: ({ adminUser }: { adminUser: AdminUser }) => { return adminUser.dbUser.id; } } ] } ] }); ``` -------------------------------- ### Bypass WebSocket Subscription Authorization with /opentopic/ in TypeScript Source: https://adminforth.dev/docs/tutorial/Customization/websocket This example shows how topics starting with `/opentopic/` bypass the `websocketTopicAuth` check, allowing any user to subscribe. This is typically used for internal AdminForth features like menu badges. ```typescript // Topics starting with /opentopic/ will bypass websocketTopicAuth check. // Example: /opentopic/some/path ``` -------------------------------- ### Install Markdown Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/markdown Install the Markdown plugin package via pnpm to enable Markdown support in your AdminForth project. ```bash pnpm install @adminforth/markdown --save ``` -------------------------------- ### Create AdminForth Plugin Project Source: https://adminforth.dev/docs/tutorial/Advanced/plugin-development This snippet demonstrates the command-line steps to create a new AdminForth plugin project. It initializes the project directory, sets up TypeScript configuration, creates initial plugin files, and installs necessary dependencies. ```bash mkdir -p af-plugin-chatgpt cd af-plugin-chatgpt npx adminforth create-plugin ``` -------------------------------- ### Install AdminForth User Soft Delete Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/user-soft-delete Installs the necessary npm package for soft deleting users within an AdminForth project. ```shell pnpm install @adminforth/user-soft-delete --save ``` -------------------------------- ### Initialize Database with Prisma Source: https://adminforth.dev/docs/tutorial/gettingStarted Creates initial database migrations using Prisma and applies them. This command is used after modifying the `schema.prisma` file to reflect database schema changes. ```bash pnpm makemigration --name init ``` ```bash pnpm makemigration --name init ; pnpm migrate:local ``` -------------------------------- ### Initialize Custom Component Directory Source: https://adminforth.dev/docs/tutorial/hello-world Commands to create and initialize a custom directory for AdminForth components using npm. ```bash cd ./custom npm init -y ``` -------------------------------- ### Install List In-Place Edit Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/list-in-place-edit Install the necessary package via pnpm to enable in-place editing functionality in your AdminForth project. ```shell pnpm i @adminforth/list-in-place-edit --save ``` -------------------------------- ### Create AdminForth Application with CLI Source: https://adminforth.dev/docs/tutorial/gettingStarted Scaffolds a new AdminForth project using the `create-app` command. It can be used with interactive prompts or by providing options like app name and database connection string. ```bash npx adminforth create-app --app-name myadmin --db "sqlite://.db.sqlite" ``` ```bash npx adminforth create-app ``` -------------------------------- ### CLI Command: resource Source: https://adminforth.dev/docs/tutorial/CLICommands Scaffolds a new AdminForth resource based on a database table and registers it in the application. ```APIDOC ## CLI COMMAND: resource ### Description Generates a new resource file for a selected database table and automatically integrates it into the AdminForth application configuration. ### Usage `adminforth resource` ### Process 1. Fetches available database tables. 2. Prompts the user to select a table. 3. Creates a resource file (e.g., `resources/users.ts`). 4. Updates `index.ts` to register the resource. 5. Adds a default navigation menu item. ### Response Example ``` πŸ” Choose a table to generate a resource for: > maindb.users βœ… Generated resource file: ./resources/users.ts βœ… Injected resource "users" into index ``` ``` -------------------------------- ### SQL Index Creation for Performance Source: https://adminforth.dev/docs/tutorial/Customization/dataApi Demonstrates how to create SQL indexes to optimize common queries. Proper indexing is crucial for performance on large datasets, especially for queries involving filters and sorting. ```sql CREATE INDEX idx_users_role ON users(role, createdAt); ``` ```sql CREATE INDEX idx_users_name_role ON users(name, role); ``` -------------------------------- ### Install AdminForth Rich Editor Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/RichEditor Install the required package via pnpm to enable the rich text editor functionality in your AdminForth project. ```shell pnpm i @adminforth/rich-editor --save ``` -------------------------------- ### Navigate to Project Directory Source: https://adminforth.dev/docs/tutorial/gettingStarted Changes the current directory to the newly created AdminForth project folder. ```bash cd myadmin ``` -------------------------------- ### Install Twitch OAuth Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Twitch OAuth adapter, adding support for Twitch authentication. This is beneficial for platforms targeting streamers or creators. ```bash pnpm i @adminforth/twitch-oauth-adapter ``` -------------------------------- ### Install AdminForth Import-Export Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/import-export Use the package manager to add the plugin dependency to your project. This command installs the necessary library for CSV data handling. ```bash pnpm install @adminforth/import-export --save ``` -------------------------------- ### Execute Database Migrations Source: https://adminforth.dev/docs/tutorial/hello-world Command to run the Prisma migration process to initialize the database structure. ```bash npm run makemigration --name init ; npm run migrate:local ``` -------------------------------- ### Configure 2FA Setup Skip Policy Source: https://adminforth.dev/docs/tutorial/Plugins/TwoFactorsAuth Allows specific users to bypass the mandatory 2FA setup process by providing a filter function to the TwoFactorsAuthPlugin configuration. ```typescript plugins: [ new TwoFactorsAuthPlugin ({ twoFaSecretFieldName: 'secret2fa', usersFilterToAllowSkipSetup: (adminUser: AdminUser) => { return (['adminforth', 'adminguest'].includes(adminUser.dbUser.email)); }, }), ] ``` -------------------------------- ### CLI Command: help Source: https://adminforth.dev/docs/tutorial/CLICommands Displays a list of all available AdminForth CLI commands and their descriptions. ```APIDOC ## CLI COMMAND: help ### Description Outputs a summary of all supported AdminForth commands in the terminal for quick reference. ### Usage `adminforth help` or `adminforth --help` ### Output ``` Available commands: create-app Create a new AdminForth app create-plugin Create a plugin for your AdminForth app generate-models Generate TypeScript models from your databases bundle Bundles your AdminForth app SPA for production component Scaffold a custom Vue component resource Scaffold a custom resource ``` ``` -------------------------------- ### Display AdminForth CLI Help (CLI) Source: https://adminforth.dev/docs/tutorial/CLICommands Displays a list of all available AdminForth CLI commands with brief descriptions. This command is useful as a quick reference for developers. ```CLI adminforth help --help -h ``` -------------------------------- ### Install Mailgun Email Adapter Source: https://adminforth.dev/docs/tutorial/ListOfAdapters Installs the Mailgun email adapter for sending transactional or marketing emails through the Mailgun service. It's designed for developer-friendly email integration. ```bash pnpm i @adminforth/email-adapter-mailgun ``` -------------------------------- ### Configure logging levels via environment variables Source: https://adminforth.dev/docs/tutorial/UsageOfLogger Shows how to set environment variables to control the verbosity of logs when starting the application. This allows filtering logs for specific components like the database. ```bash DB_DEBUG_LEVEL=trace pnpm start ``` -------------------------------- ### Install Foreign Inline List Plugin Source: https://adminforth.dev/docs/tutorial/Plugins/ForeignInlineList Install the Foreign Inline List plugin using pnpm. This is the first step to enable the plugin's functionality in your AdminForth project. ```bash pnpm i @adminforth/foreign-inline-list --save ``` -------------------------------- ### Execute Prisma Migrations Source: https://adminforth.dev/docs/tutorial/gettingStarted Commands to generate a new database migration and apply it to the local environment using pnpm. ```bash pnpm makemigration --name add-apartments ; pnpm migrate:local ```