### Interactive Project Setup Source: https://docs.fiveonefour.com/hosting/cli/projects/setup?lang=typescript An example of how to run the '514 project setup' command interactively, providing only the project reference. ```bash 514 project setup acme/analytics-api ``` -------------------------------- ### Initialize Project and Harness Examples Source: https://docs.fiveonefour.com/moosestack/moose-cli?lang=typescript Examples of using 'moose harness init' with different arguments and flags for project and harness setup. ```bash moose harness init my-app typescript --agent codex moose harness init --name schema --template typescript --agent none moose harness init my-app python-empty --location ./sandbox moose harness init --input request.json cat request.json | moose harness init --input - ``` -------------------------------- ### Use Documentation with AI Clients Source: https://docs.fiveonefour.com/moosestack/moose-cli?lang=typescript Pipes raw documentation content to AI clients for assistance. This example shows how to get help with a specific setup step using Claude. ```bash moose docs --raw guides/chat-in-your-app#setup | claude "do this step, ask me any questions you need to execute" ``` -------------------------------- ### List Documentation Pages Source: https://docs.fiveonefour.com/hosting/cli/doc/list Use this command to list all available documentation pages. No setup is required beyond having the CLI installed. ```bash 514 docs list [OPTIONS] ``` ```bash 514 docs list 514 docs list --expand ``` -------------------------------- ### Non-Interactive Project Setup Source: https://docs.fiveonefour.com/hosting/cli/projects/setup?lang=typescript An example of a non-interactive '514 project setup' command, demonstrating the use of various options to configure the project setup process. ```bash 514 project setup acme/analytics-api \ --path ~/dev \ --dir-name analytics-api \ --branch feature/add-orders-rollup \ --push \ --run both \ --yes \ --no-input ``` -------------------------------- ### Example Project Commands Source: https://docs.fiveonefour.com/hosting/cli/projects A collection of common examples demonstrating how to use the project commands, including listing, linking, and setting up projects, with an example of JSON output. ```bash 514 project list 514 project link acme/analytics-api 514 project setup acme/analytics-api 514 --json project list ``` -------------------------------- ### Agent CLI Examples Source: https://docs.fiveonefour.com/hosting/cli/agent Demonstrates various use cases for the 514 agent CLI, including setup and resource inspection. ```bash # Set up agent skills and MCP configuration 514 agent init # Set up for specific agents only 514 agent init --agent claude-code --agent cursor # Remove all installed skills 514 agent remove --yes # Read-only resource inspection 514 agent auth whoami 514 agent project list --json 514 agent deployment list --project my-org/my-project 514 agent stream list dep_abc123 --project my-org/my-project ``` -------------------------------- ### Start Local Development Environment Source: https://docs.fiveonefour.com/moosestack/moose-cli?lang=typescript Starts a local development environment with hot reload and automatic infrastructure management. Prerequisites include installing project dependencies for TypeScript (`npm install` or `pnpm install`) and Python (`pip install -r requirements.txt`). Use flags like `--mcp`, `--agent`, `--no-infra`, `--dockerless`, `--timestamps`, `--timing`, `--log-payloads`, and various `--yes-*` flags to customize the development experience. ```bash moose dev [--mcp] [--agent] [--no-infra] [--dockerless] [--timestamps] [--timing] [--log-payloads] [--yes-all] [--yes-destructive] [--yes-rename] ``` ```bash nohup moose dev & ``` -------------------------------- ### Post-Startup SQL Setup Script Source: https://docs.fiveonefour.com/moosestack/configuration/dev-environment Example Python script to run SQL against ClickHouse after all tables are guaranteed to exist. This is useful for setting up views in multi-database setups. ```python import os import sys import clickhouse_connect ``` -------------------------------- ### Setup a New Project Source: https://docs.fiveonefour.com/hosting/cli?lang=typescript Initiate the setup process for a new project within a specific organization. ```bash 514 project setup my-org/my-project ``` -------------------------------- ### Execute External Script on First Start Source: https://docs.fiveonefour.com/moosestack/configuration/dev-environment Configure a script to run automatically when the HTTP server starts for the first time. Useful for initial data synchronization or setup tasks. ```toml [http_server_config] on_first_start_script = "moose db pull --clickhouse-url $REMOTE_DB_URL" ``` -------------------------------- ### Base Configuration Example (.env) Source: https://docs.fiveonefour.com/moosestack/configuration Example of a committed .env file with base configuration for all environments. ```shell # Base configuration for all environments MOOSE_HTTP_SERVER_CONFIG__PORT=4000 MOOSE_CLICKHOUSE_CONFIG__DB_NAME=moose_db ``` -------------------------------- ### Development Configuration Example (.env.dev) Source: https://docs.fiveonefour.com/moosestack/configuration Example of a committed .env.dev file with development-specific settings. ```shell # Development settings MOOSE_LOGGER__LEVEL=debug MOOSE_FEATURES__WORKFLOWS=false ``` -------------------------------- ### Install Basic Linux Tools Source: https://docs.fiveonefour.com/moosestack/help/windows-setup?lang=typescript Optionally install essential development tools like build-essential, curl, and git. ```bash sudo apt install -y build-essential curl git ``` -------------------------------- ### Initialize Project from ClickHouse with 514 CLI Source: https://docs.fiveonefour.com/moosestack/release-notes/2026-04-01 Use `moose init --from-clickhouse` to start a new project based on an existing ClickHouse setup, following a guided CLI installation path. ```bash moose init --from-clickhouse ``` -------------------------------- ### Initialize New Project Examples Source: https://docs.fiveonefour.com/moosestack/moose-cli?lang=typescript Examples demonstrating different ways to initialize a new project using the 'moose init' command with various options. ```bash moose init --name my-app --template typescript moose init --name my-app moose init --name my-app --template typescript-empty --from-remote ``` -------------------------------- ### List SQL Resources Examples Source: https://docs.fiveonefour.com/hosting/cli/sql-resource/list?lang=typescript Examples demonstrating how to list SQL resources for a specific deployment, including specifying the project context. ```bash 514 sql-resource list dep_abc123 --project my-org/my-project ``` ```bash 514 sql-resources list dep_abc123 --project my-org/my-project ``` -------------------------------- ### Workflow Definition Example Source: https://docs.fiveonefour.com/moosestack/reference Example of creating a workflow with a starting task, schedule, timeout, and retry configuration. ```TypeScript const myWorkflow = new Workflow("getData", { startingTask: callAPI, schedule: "@every 5s", // Run every 5 seconds timeout: "1h", retries: 3 }); ``` -------------------------------- ### Example Search for 'deployment' Source: https://docs.fiveonefour.com/hosting/cli/doc/search Demonstrates searching for documentation related to 'deployment'. ```bash 514 docs search "deployment" ``` -------------------------------- ### Install Node.js using NVM on WSL2 Source: https://docs.fiveonefour.com/moosestack/release-notes/2026-02-12?lang=typescript Step-by-step guide to install Node.js using NVM within WSL2 Ubuntu. Avoids conflicts with Windows installations. ```bash # Install NVM (Node Version Manager) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash # Source NVM to make it available in the current session export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && ". "$NVM_DIR/nvm.sh" # Install the latest LTS version of Node.js nvm install --lts # Use the installed version nvm use --lts # Verify installation node -v ``` -------------------------------- ### Fiveonefour CLI: Setup and Link Commands Source: https://docs.fiveonefour.com/moosestack/release-notes/2026-02-19 Use the Fiveonefour CLI for project onboarding. The `setup` command clones and configures new projects, while `link` connects existing local repositories. Both support authentication and interactive/non-interactive modes. ```bash # Clone and set up a new project from Fiveonefour 514 setup acme/analytics-api --path ./my-analytics-app --branch feature/new-dashboard # The setup command automatically: # - Clones the repository # - Creates the specified branch # - Links the repo to Fiveonefour project # - Sets up deployment configuration # Link an existing local repository to a Fiveonefour project cd /path/to/existing/repo 514 link --project acme/marketing-dashboard --yes # Or use interactive mode to select from available projects 514 link ``` -------------------------------- ### Install GitHub Actions Runner as a Service Source: https://docs.fiveonefour.com/moosestack/deploying/deploying-with-docker-compose?lang=typescript Installs and starts the GitHub Actions runner as a system service, ensuring it runs automatically. ```bash cd actions-runner sudo ./svc.sh install sudo ./svc.sh start ``` -------------------------------- ### Show Documentation Page with Web Option Source: https://docs.fiveonefour.com/hosting/cli/doc/show?lang=typescript Example of displaying a documentation page for 'guides/chat-in-your-app#overview' and opening it in a web browser. ```bash 514 docs show guides/chat-in-your-app#overview --web ``` -------------------------------- ### Setup Fiveonefour Project Source: https://docs.fiveonefour.com/hosting/troubleshooting/setup-failures?lang=typescript Execute this command to set up a new project or link an existing one. Use it when the project cannot be resolved or accessed due to an incorrect organization/project slug or missing permissions. ```bash 514 project setup / ``` -------------------------------- ### List Stream Resources Example Source: https://docs.fiveonefour.com/hosting/cli/stream/list?lang=typescript Examples demonstrating how to list stream resources for a given deployment ID, specifying the project context. ```bash 514 stream list dep_abc123 --project my-org/my-project ``` ```bash 514 streams list dep_abc123 --project my-org/my-project ``` -------------------------------- ### HTTP Server Configuration Example Source: https://docs.fiveonefour.com/moosestack/configuration/http-server?lang=typescript Configure the host, ports, and startup/reload scripts for the local development server. ```toml [http_server_config] # Host to bind the webserver to (Default: "localhost") host = "localhost" # Port for the main API server (Default: 4000) port = 4000 # Port for the management server (Default: 5001) management_port = 5001 # Script to run once when moose dev first starts (optional) on_first_start_script = "uv run python app/scripts/setup_views.py" # Script to run after every successful reload (optional) on_reload_complete_script = "uv run python app/scripts/setup_views.py" ``` -------------------------------- ### List Web Apps Example Source: https://docs.fiveonefour.com/hosting/cli/web-app Examples demonstrating how to list web applications for a given deployment ID, with project context specified. The plural alias `web-apps` also works. ```bash 514 web-app list dep_abc123 --project my-org/my-project ``` ```bash 514 web-apps list dep_abc123 --project my-org/my-project ``` -------------------------------- ### Moose CLI Version Output Source: https://docs.fiveonefour.com/guides/performant-dashboards/tutorial?chat-deploy-completed=%5B%5D&lang=typescript Example output confirming the Moose CLI version. This indicates a successful installation and availability in your terminal. ```bash moose X.X.X ``` -------------------------------- ### Example: List Web Apps with Project Context Source: https://docs.fiveonefour.com/hosting/cli/web-app/list?lang=typescript Demonstrates how to list web apps for a given deployment ID, specifying the project context. This is useful when operating outside of a linked repository. ```bash 514 web-app list dep_abc123 --project my-org/my-project ``` -------------------------------- ### Example API Request for Visits Source: https://docs.fiveonefour.com/moosestack/apis/semantic-layer Demonstrates a sample HTTP GET request to the visits API endpoint with specific query parameters. ```http GET /api/visits?studio_id=5&dimensions=day&metrics=noShows&start_date_gte=2025-01-01 ``` -------------------------------- ### Initialize Agent Skills and MCP Configuration Source: https://docs.fiveonefour.com/hosting/cli/agent?lang=typescript Example of setting up agent skills and MCP configuration using the init command. ```bash # Set up agent skills and MCP configuration 514 agent init ``` -------------------------------- ### Advanced Express App Setup with TypeScript Source: https://docs.fiveonefour.com/moosestack/app-api-frameworks/express?lang=typescript Demonstrates a complete Express application setup including middleware, custom logging, error handling, and various API endpoints (GET, POST, protected). It also shows how to register the Express app as a WebApp. ```typescript import express, { Request, Response, NextFunction } from "express"; import { WebApp, getMooseUtils } from "@514labs/moose-lib"; import { UserEvents } from "../tables/UserEvents"; import { UserProfile } from "../tables/UserProfile"; const app = express(); // Middleware setup app.use(express.json()); // Custom logging middleware app.use((req: Request, res: Response, next: NextFunction) => { console.log(`${req.method} ${req.path}`); next(); }); // Error handling middleware const asyncHandler = (fn: Function) => (req: Request, res: Response, next: NextFunction) => { Promise.resolve(fn(req, res, next)).catch(next); }; // Health check endpoint app.get("/health", (req, res) => { res.json({ status: "ok", timestamp: new Date().toISOString() }); }); // GET endpoint with query parameters app.get("/users/:userId/events", asyncHandler(async (req: Request, res: Response) => { const { client, sql } = await getMooseUtils(); const { userId } = req.params; const limit = parseInt(req.query.limit as string) || 10; const eventType = req.query.eventType as string; const cols = UserEvents.columns; const query = sql.statement` SELECT ${cols.id}, ${cols.event_type}, ${cols.timestamp} FROM ${UserEvents} WHERE ${cols.user_id} = ${userId} ${eventType ? sql.fragment`AND ${cols.event_type} = ${eventType}` : sql.fragment``} ORDER BY ${cols.timestamp} DESC LIMIT ${limit} `; const result = await client.query.execute(query); const events = await result.json(); res.json({ userId, count: events.length, events }); })); // POST endpoint app.post("/users/:userId/profile", asyncHandler(async (req: Request, res: Response) => { const { userId } = req.params; const { name, email } = req.body; // Validation if (!name || !email) { return res.status(400).json({ error: "Name and email are required" }); } // Handle POST logic here res.json({ success: true, userId, profile: { name, email } }); })); // Protected endpoint with JWT app.get("/protected", asyncHandler(async (req: Request, res: Response) => { const moose = await getMooseUtils(); if (!moose.jwt) { return res.status(401).json({ error: "Unauthorized" }); } const userId = moose.jwt.sub; res.json({ message: "Authenticated", userId, claims: moose.jwt }); })); // Error handling app.use((err: Error, req: Request, res: Response, next: NextFunction) => { console.error(err); res.status(500).json({ error: "Internal Server Error", message: err.message }); }); // Register as WebApp export const advancedExpressApp = new WebApp("advancedExpress", app, { mountPath: "/api/v1", metadata: { description: "Advanced Express API with routing and middleware" } }); ``` -------------------------------- ### List Organizations Source: https://docs.fiveonefour.com/hosting/cli/orgs/list Use this command to list all organizations available to the current authenticated user. No setup is required beyond having the CLI installed and authenticated. ```bash 514 org list ``` -------------------------------- ### Example: List Web Apps (Alternative Syntax) Source: https://docs.fiveonefour.com/hosting/cli/web-app/list?lang=typescript An alternative syntax for listing web apps, showing flexibility in command structure. Ensure the deployment ID and project context are correctly provided. ```bash 514 web-apps list dep_abc123 --project my-org/my-project ``` -------------------------------- ### Example Search for 'workflow' Source: https://docs.fiveonefour.com/hosting/cli/doc/search Demonstrates searching for documentation related to 'workflow'. ```bash 514 docs search "workflow" ``` -------------------------------- ### Define Query Helper in Next.js Source: https://docs.fiveonefour.com/moosestack/getting-started/existing-app/next-js Define a query helper that uses the shared client and export it from your 'moose' package. This example provides a basic query for starting. ```typescript import { sql } from "@514labs/moose-lib"; import { Events, EventModel } from "./models"; import { executeQuery } from "./client"; export async function getEvents(limit: number = 10): Promise { return await executeQuery( sql.statement`SELECT * FROM ${Events} ORDER BY ${Events.columns.event_time} DESC LIMIT ${limit}`, ); } ``` -------------------------------- ### Complete Koa Application with Middleware Source: https://docs.fiveonefour.com/moosestack/app-api-frameworks/koa?lang=typescript A comprehensive Koa.js application example demonstrating middleware setup, routing, custom error handling, logging, and database integration. ```typescript import Koa, { Context, Next } from "koa"; import Router from "@koa/router"; import bodyParser from "koa-bodyparser"; import logger from "koa-logger"; import { WebApp, getMooseUtils } from "@514labs/moose-lib"; import { UserEvents } from "../tables/UserEvents"; import { UserProfile } from "../tables/UserProfile"; const app = new Koa(); const router = new Router(); // Middleware app.use(logger()); app.use(bodyParser()); // Custom error handling middleware app.use(async (ctx: Context, next: Next) => { try { await next(); } catch (error) { ctx.status = error.status || 500; ctx.body = { error: error.message || "Internal Server Error" }; ctx.app.emit("error", error, ctx); } }); // Custom logging middleware app.use(async (ctx: Context, next: Next) => { const start = Date.now(); await next(); const ms = Date.now() - start; console.log(`${ctx.method} ${ctx.url} - ${ms}ms`); }); // Health check router.get("/health", (ctx) => { ctx.body = { status: "ok", timestamp: new Date().toISOString() }; }); // GET with params and query router.get("/users/:userId/events", async (ctx) => { const { client, sql } = await getMooseUtils(); const { userId } = ctx.params; const limit = parseInt((ctx.query.limit as string) || "10"); const eventType = ctx.query.eventType as string; const cols = UserEvents.columns; const query = sql.statement` SELECT ${cols.id}, ${cols.event_type}, ${cols.timestamp} FROM ${UserEvents} WHERE ${cols.user_id} = ${userId} ${eventType ? sql.fragment`AND ${cols.event_type} = ${eventType}` : sql.fragment``} ORDER BY ${cols.timestamp} DESC LIMIT ${limit} `; const result = await client.query.execute(query); const events = await result.json(); ctx.body = { userId, count: events.length, events }; }); // POST endpoint router.post("/users/:userId/events", async (ctx) => { const { userId } = ctx.params; const { eventType, data } = ctx.request.body as any; // Validation if (!eventType || !data) { ctx.throw(400, "eventType and data are required"); } // Handle POST logic ctx.body = { success: true, userId, eventType, data }; ctx.status = 201; }); // Protected route with JWT router.get("/protected", async (ctx) => { const { jwt } = await getMooseUtils(); if (!jwt) { ctx.throw(401, "Unauthorized"); } const userId = jwt.sub; const userRole = jwt.role; ctx.body = { message: "Authenticated", userId, role: userRole }; }); // Multiple route handlers (middleware chain) const checkAuth = async (ctx: Context, next: Next) => { const { jwt } = await getMooseUtils(); if (!jwt) { ctx.throw(401, "Unauthorized"); } await next(); }; router.get("/admin/stats", checkAuth, async (ctx) => { // jwt is guaranteed to exist here via checkAuth middleware ctx.body = { stats: "admin stats" }; }); app.use(router.routes()); app.use(router.allowedMethods()); // Error listener app.on("error", (err, ctx) => { console.error("Server error:", err); }); export const advancedKoaApp = new WebApp("advancedKoa", app, { mountPath: "/api/v1", metadata: { description: "Advanced Koa API with middleware chain" } }); ``` -------------------------------- ### 514 Project Setup Syntax Source: https://docs.fiveonefour.com/hosting/cli/projects/setup?lang=typescript Displays the general syntax for the '514 project setup' command, including placeholders for options and the project reference. ```bash 514 project setup [OPTIONS] ``` -------------------------------- ### Examples of 514 env Commands Source: https://docs.fiveonefour.com/hosting/cli/env Demonstrates practical usage of '514 env' commands for listing, getting, setting, and deleting variables with project and branch scoping. ```bash 514 env list --project acme/analytics-api ``` ```bash 514 env get DATABASE_URL --project acme/analytics-api ``` ```bash 514 env set API_KEY=sk-123 --project acme/analytics-api ``` ```bash 514 env set API_KEY=sk-123 BATCH_SIZE=100 --project acme/analytics-api --branch feature/new-ingest ``` ```bash 514 env delete OLD_SECRET --project acme/analytics-api ``` -------------------------------- ### Initialize New Project (Preferred Syntax) Source: https://docs.fiveonefour.com/moosestack/moose-cli?lang=typescript Initializes a new project with a specified name, template, and location. Supports initializing from a remote database and custom Dockerfile generation. ```bash moose init --name [--template