npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

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

About

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

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

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

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

Open Software & Tools

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

© 2025 – Pkg Stats / Ryan Hefner

@foxen/cli

v1.4.0

Published

CLI for Foxen - generate, build, and develop Elysia routes

Readme

@foxen/cli

Command-line tools for Foxen projects. Provides commands for initializing, developing, generating, and migrating.

Installation

# Global installation
bun add -g @foxen/cli

# Or use with bunx
bunx foxn <command>

Commands

foxen init

Initialize a new foxen.config.ts file:

foxen init
foxen init --force    # Overwrite existing
foxen init --js       # Create JavaScript config

foxen generate

Generate Elysia routes from your Next.js API structure:

foxen generate
foxen generate --watch           # Watch mode
foxen generate -r ./src/api      # Custom routes directory
foxen generate -o ./src/gen      # Custom output directory
foxen generate -v                # Verbose output

foxen dev

Start development server with hot reload:

foxen dev
foxen dev --port 8080            # Custom port
foxen dev --host 0.0.0.0         # Custom host
foxen dev -c ./custom.config.ts  # Custom config

foxen migrate

Migrate a Next.js project to standalone Elysia:

foxen migrate ./my-nextjs-app
foxen migrate ./source -o ./dest   # Custom output
foxen migrate --dry-run            # Preview only
foxen migrate --docker             # Include Docker files
foxen migrate --tests              # Include test stubs

Configuration

Create a foxen.config.ts in your project root:

import { defineConfig } from "@foxen/cli";

export default defineConfig({
    // Directory containing Next.js App Router API routes
    routesDir: "./src/app/api",

    // Output directory for generated code
    outputDir: "./src/generated",

    // Base path for all API routes
    basePath: "/api",

    // Output format: "ts" or "js"
    format: "ts",

    // Generate barrel export (index.ts)
    generateBarrel: true,

    // Group routes by directory
    useGroups: false,

    // Import alias for routes (e.g., "@/app/api")
    routesAlias: undefined,

    // Path to tsconfig.json
    tsConfigPath: "./tsconfig.json",

    // Patterns to ignore
    ignorePatterns: ["**/*.test.ts", "**/__tests__/**"],

    // Name of Elysia instance in generated code
    elysiaInstanceName: "app",
});

Options Reference

Global Options

| Option | Description | |--------|-------------| | -h, --help | Show help | | --version | Show version |

generate

| Option | Description | |--------|-------------| | -c, --config <path> | Path to config file | | -r, --routes <path> | Routes directory | | -o, --output <path> | Output directory | | -w, --watch | Watch mode | | -v, --verbose | Verbose output |

dev

| Option | Description | |--------|-------------| | -c, --config <path> | Path to config file | | -p, --port <port> | Server port (default: 3000) | | -h, --host <host> | Server host (default: localhost) |

migrate

| Option | Description | |--------|-------------| | -o, --output <path> | Output directory | | -n, --name <name> | Project name | | -r, --runtime <runtime> | Target runtime: bun or node | | -f, --force | Overwrite existing | | -d, --dry-run | Preview only | | --tests | Generate test stubs | | --docker | Generate Docker files | | -v, --verbose | Verbose output |

Programmatic Usage

You can also use the CLI commands programmatically:

import { generate, dev, init } from "@foxen/cli";

// Generate routes
await generate({
    routes: "./src/app/api",
    output: "./src/generated",
    watch: false,
    verbose: true,
});

// Start dev server
await dev({
    port: 3000,
    host: "localhost",
});

// Initialize config
await init({
    force: false,
    typescript: true,
});

Examples

Quick Start

# Initialize new project
mkdir my-api && cd my-api
bun init
bun add @foxen/cli @foxen/adapter @foxen/core elysia

# Create config
bunx foxn init

# Create a route
mkdir -p src/app/api/hello
cat > src/app/api/hello/route.ts << 'EOF'
import { NextRequest, NextResponse } from "@foxen/core";

export async function GET(request: NextRequest) {
    return NextResponse.json({ message: "Hello, World!" });
}
EOF

# Generate and run
bunx foxn generate
bunx foxn dev

Development Workflow

# Start dev server with hot reload
bunx foxn dev

# Or use generate with watch mode
bunx foxn generate --watch

Production Build

# Generate optimized routes
bunx foxn generate

# Build your app
bun build ./src/index.ts --outdir ./dist

License

MIT