### Project Setup and Dependencies Installation Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/01-helloWorld.md Creates a new project directory, initializes a Node.js project, and installs necessary AdminForth and development dependencies. ```bash mkdir af-hello cd af-hello pnpm init pnpm add adminforth express@^4 @dotenvx/dotenvx @types/express typescript tsx @types/node prisma @prisma/client -D npx --yes tsc --init --module NodeNext --target ESNext ``` -------------------------------- ### Initialize Nuxt Project and Install Dependencies Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2024-10-01-ai-blog/index.md Use this command to create a new Nuxt project, navigate into its directory, install Sass, and start the development server. ```bash npx nuxi@latest init seo cd seo npm install -D sass-embedded npm run dev ``` -------------------------------- ### Setup and Run Dev Demo Source: https://github.com/devforth/adminforth/blob/main/README.md Commands to set up and run the development demo environment. Ensure Node.js 20, Docker, pnpm, and Taskfile are installed. ```sh cd dev-demo pnpm setup-dev-demo pnpm migrate:all pnpm start ``` -------------------------------- ### MinIO Storage Adapter Setup Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/04-storage-adapters.md Example setup for the S3 compatible storage adapter using MinIO. Ensure the leveldb adapter is configured with a persistent path for keys. ```typescript import LevelDBKeyValueAdapter from '@adminforth/key-value-adapter-leveldb'; new AdminForthAdapterS3CompatibleStorage({ accessKeyId: 'minioadmin', secretAccessKey: 'minioadmin', endpoint: 'http://localhost:9000', bucket: 'adminforth-dev-demo', region: 'us-east-1', s3ACL: 'private', cleanupKeyValueAdapter: new LevelDBKeyValueAdapter({ // ensure /stores/ folder is a persisted/backed up point, if you running in docker ensure ensure you mount /stores/ as volume dbPath: process.env.NODE_ENV === production ? '/stores/minio_storage_keys' : './minio_storage_keys', }), forcePathStyle: true, cleanupCheckInterval: '30m', cleanupGracePeriod: '5d' }), ``` -------------------------------- ### Setup Terraform and Kubectl in GitHub Actions Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2026-06-01-branch-sandboxing-k3s/index.md Installs Terraform using the `hashicorp/setup-terraform` action, preparing the environment for infrastructure management. ```yaml - name: Setup Terraform & Kubectl uses: hashicorp/setup-terraform@v3 ``` -------------------------------- ### Start Development Server Source: https://github.com/devforth/adminforth/blob/main/dev-demo/README.md Starts the AdminForth development server. ```bash pnpm run dev ``` -------------------------------- ### Index.ts for AdminForth Application Setup Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/01-helloWorld.md This file initializes the AdminForth application, configures resources, authentication, customization, and starts the server. ```typescript import express from 'express'; import AdminForth from 'adminforth'; import usersResource from "./resources/adminuser.js"; import { fileURLToPath } from 'url'; import path from 'path'; import { Filters } from 'adminforth'; import { initApi } from './api.js'; import { logger } from 'adminforth'; const ADMIN_BASE_URL = ''; export const admin = new AdminForth({ baseUrl: ADMIN_BASE_URL, auth: { usersResourceId: 'adminuser', usernameField: 'email', passwordHashField: 'password_hash', rememberMeDuration: '30d', loginBackgroundImage: 'https://images.unsplash.com/photo-1534239697798-120952b76f2b?q=80&w=3389&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', loginBackgroundPosition: '1/2', loginPromptHTML: async () => { const adminforthUserExists = await admin.resource("adminuser").count(Filters.EQ('email', 'adminforth')) > 0; if (adminforthUserExists) { return "Please use adminforth as username and adminforth as password" } }, }, customization: { brandName: "myadmin", title: "myadmin", datesFormat: 'DD MMM', timeFormat: 'HH:mm a', showBrandNameInSidebar: true, showBrandLogoInSidebar: true, emptyFieldPlaceholder: '-', styles: { colors: { light: { primary: '#1a56db', sidebar: { main: '#f9fafb', text: '#213045' }, }, dark: { primary: '#82ACFF', sidebar: { main: '#1f2937', text: '#9ca3af' }, } } }, }, dataSources: [ { id: 'maindb', url: `${process.env.DATABASE_URL}` }, ], resources: [ usersResource ], menu: [ { type: 'heading', label: 'SYSTEM' }, { label: 'Users', icon: 'flowbite:user-solid', resourceId: 'adminuser' } ], }); if (fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) { const app = express(); app.use(express.json()); initApi(app, admin); const port = 3500; admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => { logger.info('Bundling AdminForth SPA done.'); }); admin.express.serve(app); admin.discoverDatabases().then(async () => { if (await admin.resource('adminuser').count() === 0) { await admin.resource('adminuser').create({ email: 'adminforth', password_hash: await AdminForth.Utils.generatePasswordHash('adminforth'), role: 'superadmin', }); } }); admin.express.listen(port, () => { logger.info(`\x1b[38;5;249m ⚡ AdminForth is available at\x1b[1m\x1b[38;5;46m http://localhost:${port}${ADMIN_BASE_URL}\x1b[0m\n`); }); } ``` -------------------------------- ### Install Open Signup Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/09-open-signup.md Install the Open Signup plugin using pnpm. ```bash pnpm install @adminforth/open-signup --save ``` -------------------------------- ### Install Redis Key-Value Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/07-key-value-adapters.md Installs the Redis adapter for centralized key-value storage. Ideal for multi-process or replica-based installations. ```bash pnpm i @adminforth/key-value-adapter-redis ``` -------------------------------- ### Cloudflare R2 Storage Adapter Setup Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/04-storage-adapters.md Example setup for the S3 compatible storage adapter using Cloudflare R2. Ensure the leveldb adapter is configured with a persistent path for keys. ```typescript import LevelDBKeyValueAdapter from '@adminforth/key-value-adapter-leveldb'; new AdminForthAdapterS3CompatibleStorage({ accessKeyId: process.env.R2_ACCESS_KEY_ID as string, secretAccessKey: process.env.R2_SECRET_ACCESS_KEY as string, endpoint: process.env.R2_ENDPOINT_URL as string, bucket: process.env.R2_BUCKET_NAME as string, region: process.env.R2_BUCKET_REGION as string, s3ACL: "private", cleanupKeyValueAdapter: new LevelDBKeyValueAdapter({ // ensure /stores/ folder is a persisted/backed up point, if you running in docker ensure ensure you mount /stores/ as volume dbPath: process.env.NODE_ENV === production ? '/stores/cloudflare_r2_storage_keys' : './cloudflare_r2_storage_keys', }), forcePathStyle: true, cleanupCheckInterval: '30m', cleanupGracePeriod: '5d' }), ``` -------------------------------- ### Install Upload Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/05-0-upload.md Install the core upload plugin using pnpm. ```bash pnpm i @adminforth/upload --save ``` -------------------------------- ### Install Upload and Local Storage Plugins Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/06-markdown.md Install the necessary plugins for handling file uploads and local storage. ```bash pnpm i @adminforth/upload --save pnpm i @adminforth/storage-adapter-local --save ``` -------------------------------- ### Install Keycloak Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/11-oauth.md Install the Keycloak OAuth adapter using pnpm. ```bash pnpm install @adminforth/oauth-adapter-keycloak --save ``` -------------------------------- ### Install Dependencies Source: https://github.com/devforth/adminforth/blob/main/dev-demo/README.md Run this command to install all project dependencies using pnpm. ```bash pnpm ci ``` -------------------------------- ### Install Inline Create Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/12-inline-create.md Install the Inline Create plugin using pnpm. ```bash pnpm install @adminforth/inline-create --save ``` -------------------------------- ### Install Local Storage Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/04-storage-adapters.md Install the local storage adapter package using pnpm. ```bash pnpm add @adminforth/storage-adapter-local ``` -------------------------------- ### Install OAuth Plugin and Google Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/11-oauth.md Install the core OAuth plugin and the Google OAuth adapter using pnpm. ```bash pnpm install @adminforth/oauth --save pnpm install @adminforth/oauth-adapter-google --save ``` -------------------------------- ### Start AdminForth Project Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2024-10-01-ai-blog/index.md Use this command to start your AdminForth project if it was not run previously. ```bash npm start ``` -------------------------------- ### Install Google Gemini Completion Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/05-ai-completion-adapters.md Install the Google Gemini completion adapter package using pnpm. ```bash pnpm i @adminforth/completion-adapter-google-gemini ``` -------------------------------- ### Install Text Complete and OpenAI Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/14-text-complete.md Install the necessary packages for the Text Complete plugin and its OpenAI adapter. ```bash pnpm i @adminforth/text-complete --save pnpm i @adminforth/completion-adapter-openai-responses --save ``` -------------------------------- ### Install Email Invite Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/16-email-invite.md Install the Email Invite plugin using pnpm. ```bash pnpm install @adminforth/email-invite --save ``` -------------------------------- ### Start Local Development Server Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/README.md Starts a local development server that automatically refreshes on changes. Opens in your browser. ```bash $ yarn start ``` -------------------------------- ### Install Universal Search Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/18-universal-filters.md Install the Universal Search plugin using pnpm. ```bash pnpm i @adminforth/universal-search --save ``` -------------------------------- ### Database Migration and Application Start Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/01-helloWorld.md Commands to create the database migration and start the Admin Forth application. ```bash pnpm run makemigration --name init ; pnpm run migrate:local ``` ```bash pnpm start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/devforth/adminforth/blob/main/tests/application/README.md Run this command to install all necessary project dependencies using pnpm. ```bash pnpm i ``` -------------------------------- ### Install Terraform Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-11-04-k3s-ec2-deployment/index.md Installs Terraform on Ubuntu using HashiCorp's official repository. Ensure you have `wget` and `gpg` installed. ```bash wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install terraform ``` -------------------------------- ### Install OpenAI Audio Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/01-agent.md Install the necessary package for OpenAI audio adapter integration. ```bash pnpm add @adminforth/audio-adapter-openai ``` -------------------------------- ### Install Helmfile and Helm-Diff Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-11-04-k3s-ec2-deployment/index.md Installs Helmfile, a declarative spec for deploying Helm charts, and the Helm-Diff plugin for comparing Helm releases. Ensure you have `wget` and `tar` installed. ```bash wget -O helmfile_linux_amd64.tar.gz https://github.com/helmfile/helmfile/releases/download/v0.162.0/helmfile_0.162.0_linux_amd64.tar.gz tar -zxvf helmfile_linux_amd64.tar.gz sudo mv helmfile /usr/local/bin/helmfile rm helmfile_linux_amd64.tar.gz helm plugin install https://github.com/databus23/helm-diff ``` -------------------------------- ### Install Markdown Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/06-markdown.md Install the Markdown plugin using pnpm. ```bash pnpm install @adminforth/markdown --save ``` -------------------------------- ### Install Telegram Adapters Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/09-chat-surface-adapters.md Install the necessary Telegram adapters using pnpm. ```bash pnpm i @adminforth/chat-surface-adapter-telegram pnpm i @adminforth/oauth-adapter-telegram ``` -------------------------------- ### Install OpenAI Completion Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/26-RichEditor.md Install the necessary npm package for OpenAI completion responses. ```bash pnpm i @adminforth/completion-adapter-openai-responses --save ``` -------------------------------- ### Install Quick Filters Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/24-quick-filters.md Install the Quick Filters plugin using pnpm. This is the first step before integrating it into your resource. ```bash pnpm i @adminforth/quick-filters ``` -------------------------------- ### Install RAM Key-Value Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/07-key-value-adapters.md Installs the RAM adapter for in-memory key-value storage. Suitable for single-process deployments. ```bash pnpm i @adminforth/key-value-adapter-ram ``` -------------------------------- ### Install Login Captcha Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/19-login-captcha.md Install the main login captcha plugin using pnpm. ```bash pnpm i @adminforth/login-captcha ``` -------------------------------- ### Install S3 Compatible Storage Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/04-storage-adapters.md Install the S3 compatible storage adapter package using pnpm. ```bash pnpm add @adminforth/storage-adapter-s3-compatible ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/README.md Installs project dependencies using Yarn. Run this command in the project root. ```bash $ yarn ``` -------------------------------- ### Install Node.js v20 with NVM Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/001-gettingStarted.md Ensure you have Node.js v20 or higher installed and set as the default using NVM. ```bash nvm install 20 nvm alias default 20 nvm use 20 ``` -------------------------------- ### Install Two-Factor Authentication Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/02-TwoFactorsAuth.md Install the plugin using pnpm. This command adds the necessary package to your project dependencies. ```bash pnpm i @adminforth/two-factors-auth --save ``` -------------------------------- ### Initialize Database with Prisma Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/001-gettingStarted.md Create the initial database schema and apply it using Prisma's migration command. ```bash pnpm makemigration --name init ``` -------------------------------- ### Keycloak Docker Compose Configuration Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-03-25-keycloack/index.md Defines the services for PostgreSQL and Keycloak in a Docker Compose setup. Ensure Docker and Docker Compose are installed. ```yaml services: pg: image: postgres:latest environment: POSTGRES_USER: demo POSTGRES_PASSWORD: demo POSTGRES_DB: demo ports: - "5432:5432" volumes: - pg-data:/var/lib/postgresql/data keycloak: image: quay.io/keycloak/keycloak:latest command: start-dev environment: - KEYCLOAK_ADMIN=admin - KEYCLOAK_ADMIN_PASSWORD=admin - DB_VENDOR=postgres - DB_ADDR=pg - DB_DATABASE=demo - DB_USER=demo - DB_PASSWORD=demo ports: - "8080:8080" depends_on: - pg volumes: - keycloak-data:/opt/keycloak/data volumes: keycloak-data: ``` -------------------------------- ### Initialize AdminForth Project Source: https://github.com/devforth/adminforth/blob/main/README.md Run this command to create a new AdminForth project. You will be prompted to provide a database URL during the interactive setup. ```bash npx adminforth create-app ``` -------------------------------- ### Run Deployment Script Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-11-04-k3s-ec2-deployment/index.md Navigate to the deploy directory and execute the main deployment script to start the application deployment process. ```bash cd deploy ./deploy.sh ``` -------------------------------- ### Install Docker and Start Daemon on EC2 Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-02-19-compose-aws-ec2-ecr-terraform-github-actions/index.md Installs Docker and related plugins on an EC2 instance and enables the Docker daemon. It also adds the 'ubuntu' user to the 'docker' group for sudo-less Docker commands. A new SSH session is required for these group changes to take effect. ```bash apt-get update apt-get install -y --no-install-recommends \ docker-ce \ docker-ce-cli \ containerd.io \ docker-buildx-plugin \ docker-compose-plugin # Ensure Docker daemon is up systemctl enable --now docker # Allow ubuntu user to run docker without sudo (new SSH session required) usermod -aG docker ubuntu || true docker --version docker compose version echo "done" > /home/ubuntu/user_data_done ``` -------------------------------- ### Terraform User Data Script for K3s Agent Setup Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2026-06-01-branch-sandboxing-k3s/index.md This bash script is designed to be used as user data in Terraform for AWS EC2 instances. It installs AWS CLI, sets up a cron job to refresh ECR authentication tokens for K3s, and installs the K3s agent, configuring it with instance-specific metadata. ```bash #!/bin/bash set -e apt-get update apt-get install -y awscli echo '#!/bin/bash' > /usr/local/bin/update-ecr-token.sh echo 'TOKEN=$(aws ecr get-login-password --region ${aws_region})' >> /usr/local/bin/update-ecr-token.sh echo 'mkdir -p /etc/rancher/k3s' >> /usr/local/bin/update-ecr-token.sh echo 'cat < /etc/rancher/k3s/registries.yaml' >> /usr/local/bin/update-ecr-token.sh echo 'configs:' >> /usr/local/bin/update-ecr-token.sh echo ' "${account_id}.dkr.ecr.${aws_region}.amazonaws.com":' >> /usr/local/bin/update-ecr-token.sh echo ' auth:' >> /usr/local/bin/update-ecr-token.sh echo ' username: AWS' >> /usr/local/bin/update-ecr-token.sh echo ' password: "$TOKEN"' >> /usr/local/bin/update-ecr-token.sh echo 'YAML' >> /usr/local/bin/update-ecr-token.sh echo 'systemctl restart k3s-agent || true' >> /usr/local/bin/update-ecr-token.sh chmod +x /usr/local/bin/update-ecr-token.sh /usr/local/bin/update-ecr-token.sh echo "0 */10 * * * root /usr/local/bin/update-ecr-token.sh > /var/log/ecr-cron.log 2>&1" > /etc/cron.d/update-ecr-token EC2_TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") INSTANCE_ID=$(curl -H "X-aws-ec2-metadata-token: $EC2_TOKEN" -s http://169.254.169.254/latest/meta-data/instance-id) AZ=$(curl -H "X-aws-ec2-metadata-token: $EC2_TOKEN" -s http://169.254.169.254/latest/meta-data/placement/availability-zone) curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="${k3s_version}" K3S_URL="https://${public_ip}:6443" K3S_TOKEN="${k3s_token}" sh -s - agent --kubelet-arg="provider-id=aws:///$AZ/$INSTANCE_ID" ``` -------------------------------- ### Using `outputSchema` with OpenAI Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/05-ai-completion-adapters.md Demonstrates how to request structured JSON output from an AI model using the `outputSchema` parameter. This example uses the `CompletionAdapterOpenAIResponses` to get the capital of France in a JSON format. ```typescript const adapter = new CompletionAdapterOpenAIResponses({ openAiApiKey: process.env.OPENAI_API_KEY as string, model: 'gpt-5-mini', }); const prompt = 'What is the capital of France? return json'; adapter.complete({ content: prompt, maxTokens: 200, outputSchema: { name: 'capital_response', schema: { type: 'object', properties: { capital: { type: 'string' }, }, required: ['capital'], }, }, }).then((resp) => { console.log(resp); }); ``` -------------------------------- ### Create AdminForth App with CLI Options Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/001-gettingStarted.md Scaffold a new AdminForth project with specified app name and database connection string. ```bash npx adminforth create-app --app-name myadmin --db "sqlite://.db.sqlite" ``` -------------------------------- ### Terraform Null Resource for Registry Setup Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-02-19-compose-ec2-deployment-github-actions-registry/index.md Uses local-exec and remote-exec provisioners to set up a local Docker registry on the EC2 instance. This includes generating authentication secrets, certificates, and starting the registry container. ```bash set -eu echo "Generating secret for local registry" sha256sum ./.keys/id_rsa | cut -d ' ' -f1 | tr -d '\n' > ./.keys/registry.pure echo "Creating htpasswd file for local registry" docker run --rm --entrypoint htpasswd httpd:2 -Bbn ci-user $(cat ./.keys/registry.pure) > ./.keys/registry.htpasswd echo "Generating server certificate for registry" openssl genrsa -out ./.keys/registry.key 4096 echo "subjectAltName=DNS:appserver.local,DNS:localhost,IP:127.0.0.1" > san.ext openssl req -new -key ./.keys/registry.key -subj "/CN=appserver.local" -addext "$(cat san.ext)" -out ./.keys/registry.csr openssl x509 -req -days 365 -CA ./.keys/ca.pem -CAkey ./.keys/ca.key -set_serial 01 -in ./.keys/registry.csr -extfile san.ext -out ./.keys/registry.crt echo "Copying registry secret files to the instance" rsync -t -avz -e "ssh -i ./.keys/id_rsa -o StrictHostKeyChecking=no" \ ./.keys/registry.* ubuntu@${aws_eip_association.eip_assoc.public_ip}:/home/ubuntu/registry-auth ``` ```bash # remove old registry if exists docker rm -f registry # run new registry docker run -d --network host \ --name registry \ --restart always \ -v /home/ubuntu/registry-data:/var/lib/registry \ -v /home/ubuntu/registry-auth:/auth\ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/registry.htpasswd" \ -e "REGISTRY_HTTP_TLS_CERTIFICATE=/auth/registry.crt" \ -e "REGISTRY_HTTP_TLS_KEY=/auth/registry.key" \ registry:2 ``` -------------------------------- ### Define Custom API Endpoint with Zod Schema Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/03-Customization/06-customPages.md This snippet demonstrates how to define a custom GET API endpoint in `api.ts` for a dashboard. It uses `admin.express.withSchema` for validation and OpenAPI generation, and `admin.express.authorize` for authentication. Ensure Zod is installed and imported. ```typescript import type { IAdminUserExpressRequest } from 'adminforth'; import express from 'express'; import * as z from 'zod'; .... app.get(`${ADMIN_BASE_URL}/api/dashboard/`, admin.express.withSchema( { description: 'Returns aggregated apartment metrics for the custom dashboard page.', response: z.object({ apartsByDays: z.array(z.record(z.string(), z.unknown())), totalAparts: z.number(), }).catchall(z.unknown()), }, admin.express.authorize( async (req:IAdminUserExpressRequest, res: express.Response) => { const days = req.body.days || 7; const apartsByDays = admin.resource('aparts').dataConnector.client.prepare( `SELECT strftime('%Y-%m-%d', created_at) as day, COUNT(*) as count FROM apartments GROUP BY day ORDER BY day DESC LIMIT ?; ` ).all(days); const totalAparts = apartsByDays.reduce((acc: number, { count }: { count:number }) => acc + count, 0); // add listed, unlisted, listedPrice, unlistedPrice const listedVsUnlistedByDays = admin.resource('aparts').dataConnector.client.prepare( `SELECT strftime('%Y-%m-%d', created_at) as day, SUM(listed) as listed, COUNT(*) - SUM(listed) as unlisted, SUM(listed * price) as listedPrice, SUM((1 - listed) * price) as unlistedPrice FROM apartments GROUP BY day ORDER BY day DESC LIMIT ?; ` ).all(days); const apartsCountsByRooms = await admin.resource('aparts').dataConnector.client.prepare( `SELECT number_of_rooms, COUNT(*) as count FROM apartments GROUP BY number_of_rooms ORDER BY number_of_rooms; ` ).all(); const topCountries = await admin.resource('aparts').dataConnector.client.prepare( `SELECT country, COUNT(*) as count FROM apartments GROUP BY country ORDER BY count DESC LIMIT 4; ` ).all(); const totalSquare = admin.resource('aparts').dataConnector.client.prepare( `SELECT SUM(square_meter) as totalSquare FROM apartments; ` ).get(); const listedVsUnlistedPriceByDays = admin.resource('aparts').dataConnector.client.prepare( `SELECT strftime('%Y-%m-%d', created_at) as day, SUM(listed * price) as listedPrice, SUM((1 - listed) * price) as unlistedPrice FROM apartments GROUP BY day ORDER BY day DESC LIMIT ?; ` ).all(days); const totalListedPrice = Math.round(listedVsUnlistedByDays.reduce(( acc: number, { listedPrice }: { listedPrice:number } ) => acc + listedPrice, 0)); const totalUnlistedPrice = Math.round(listedVsUnlistedByDays.reduce(( acc: number, { unlistedPrice }: { unlistedPrice:number } ) => acc + unlistedPrice, 0)); res.json({ apartsByDays, totalAparts, listedVsUnlistedByDays, apartsCountsByRooms, topCountries, totalSquareMeters: totalSquare.totalSquare, totalListedPrice, totalUnlistedPrice, listedVsUnlistedPriceByDays, }); } ) ) ); ``` -------------------------------- ### Install Helm Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-11-04-k3s-ec2-deployment/index.md Installs Helm, a package manager for Kubernetes. This script downloads and executes the Helm installation script. ```bash curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod 700 get_helm.sh ./get_helm.sh ``` -------------------------------- ### Install Terraform on Ubuntu Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2024-10-01-ai-blog/index.md Installs Terraform on Ubuntu systems using apt. Ensure you have wget and gnupg installed. ```bash wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install terraform ``` -------------------------------- ### Install Ansible Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-11-04-k3s-ec2-deployment/index.md Installs Ansible on Ubuntu by adding the official Ansible PPA and then installing the package. This ensures you have the latest stable version. ```bash sudo add-apt-repository --yes --update ppa:ansible/ansible sudo apt install ansible -y ``` -------------------------------- ### Install Many2Many Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/22-many2many.md Install the plugin using pnpm. ```bash pnpm i @adminforth/many2many ``` -------------------------------- ### Copilot Instructions for Context7 Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-10-21-context7-setup/index.md Add this content to `.github/copilot-instructions.md` to instruct GitHub Copilot to always use Context7 MCP for code generation, setup, configuration, and documentation. ```txt Always use context7 when I need code generation, setup or configuration steps, or library/API documentation. This means you should automatically use the Context7 MCP tools to resolve library id and get library docs without me having to explicitly ask. ``` -------------------------------- ### Create New AdminForth Project Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2024-10-01-ai-blog/index.md Initializes a new AdminForth application with the specified name. Navigate to the project directory after creation. ```bash npx adminforth create-app --app-name ai-blog ``` -------------------------------- ### Install Clone Row Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/21-clone-row.md Install the @adminforth/clone-row package using pnpm. ```bash pnpm install @adminforth/clone-row --save ``` -------------------------------- ### Install Slack Notification Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2025-01-19-how-adminforth-manages-version/index.md Install the semantic-release-slack-bot plugin as a development dependency. ```sh npm i -D semantic-release-slack-bot ``` -------------------------------- ### Install CRUD Approve Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/28-CRUD-approve.md Installs the CRUD Approve plugin using pnpm. ```bash pnpm i @adminforth/crud-approve-plugin --save ``` -------------------------------- ### Install Agent Plugin and OpenAI Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/01-agent.md Install the necessary packages for the Agent plugin and the OpenAI completion adapter using pnpm. ```bash pnpm i @adminforth/agent --save pnpm i @adminforth/completion-adapter-openai-responses --save ``` -------------------------------- ### Install Background Jobs Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/23-background-jobs.md Install the background jobs plugin using pnpm. ```bash pnpm i @adminforth/background-jobs ``` -------------------------------- ### Install i18n and OpenAI Completion Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/10-i18n.md Install the necessary packages for the i18n plugin and the OpenAI completion adapter using pnpm. ```bash pnpm install @adminforth/i18n --save pnpm install @adminforth/completion-adapter-openai-responses --save ``` -------------------------------- ### Terraform Initialization and Apply Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2024-11-14-compose-ec2-deployment-ci/index.md Commands to initialize Terraform and apply the configuration to deploy resources. Run 'terraform init' first to download providers and modules, then 'terraform apply' to create or update infrastructure. ```Bash terraform init terraform apply -auto-approve ``` -------------------------------- ### Initialize npm and Install Dependencies Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/10-Advanced/01-plugin-development.md Initializes a new npm package in the custom plugin directory and installs the 'vue-suggestion-input' package as a development dependency. ```bash cd af-plugin-chatgpt/custom pnpm init -y pnpm i vue-suggestion-input -D ``` -------------------------------- ### Install Audit Log Plugin Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/04-AuditLog.md Install the Audit Log plugin using pnpm. ```bash pnpm i @adminforth/audit-log --save ``` -------------------------------- ### Install reCaptcha Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/08-captcha-adapters.md Install the reCaptcha adapter for captcha functionality using pnpm. ```bash pnpm i @adminforth/login-captcha-adapter-recaptcha ``` -------------------------------- ### MinIO Docker Setup Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/06-Adapters/04-storage-adapters.md Command to run a MinIO server instance using Docker for S3 compatible storage. ```bash docker run \ -p 9000:9000 \ -p 9001:9001 \ -e MINIO_ROOT_USER=minioadmin \ -e MINIO_ROOT_PASSWORD=minioadmin \ minio/minio server /data --console-address ":9001" ``` -------------------------------- ### Agent Plugin Setup Prompt Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/blog/2026-05-22-open-source-agent-existing-database/index.md A prompt for a coding agent to automate the setup of the AdminForth Agent plugin, including table creation, resource registration, and environment variable configuration. ```text Add the AdminForth Agent plugin to this app, create the required sessions and turns tables/resources for it to work using this project's existing schema-management flow, register them, attach the plugin to adminuser, and add the needed env vars. ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/001-gettingStarted.md Change the current directory to the newly created AdminForth project. ```bash cd myadmin # or any other name you provided ``` -------------------------------- ### Install Clerk OAuth Adapter Source: https://github.com/devforth/adminforth/blob/main/adminforth/documentation/docs/tutorial/09-Plugins/11-oauth.md Install the Clerk OAuth adapter package using pnpm. ```bash pnpm install @adminforth/clerk-oauth-adapter --save ```