Servercn CLI

The Servercn CLI provides a set of commands to help you manage your Servercn projects.


init

The init command bootstraps Servercn configuration in an existing project or scaffolds a new project from a starter template.


1. Existing Project

Initialize Servercn in an Existing Project

npx servercn-cli init

After running the command, you will be prompted to choose a project foundation:

  Select a project foundation:  » - Use arrow-keys. Return to submit.
  Express Starter - Minimal Express server setup
  Express + Mongoose
  Express + MySQL (Drizzle)
  Express + PostgreSQL (Drizzle)
  Nextjs Starter
> Existing Project

Choose the Existing Project and press Enter to continue.

Again, you will be prompted to configure your stack:

√ Project root directory ... .
√ Programming language » Typescript (recommended)
√ Backend framework » Express.js
√ Select architecture » MVC (controllers, services, models)
√ Select database » Mongodb
√ Mongodb library » mongoose
√ Select package manager » npm
 
Servercn initialized successfully.
 
You may now add components by running:
1. npx servercn-cli add <component>
ex: npx servercn-cli add jwt-utils error-handler http-status-codes

This generates a servercn.config.json file in your project root:

{
  "$schema": "https://servercn.vercel.app/schema/servercn.config.json",
  "version": "1.1.11",
  "rootDir": ".",
  "packageManager": "npm",
  "runtime": "node",
  "language": "typescript",
  "framework": "express",
  "architecture": "mvc",
  "database": {
    "engine": "mongodb",
    "adapter": "mongoose"
  }
}

2. New Project

Initialize a New Project from a Starter

Available starters:

  • nextjs-starter
  • express-starter
  • mongoose-starter
  • drizzle-mysql-starter
  • drizzle-pg-starter
npx servercn-cli init nextjs-starter --fw=nextjs
npx servercn-cli init express-starter
npx servercn-cli init mongoose-starter
npx servercn-cli init drizzle-mysql-starter
npx servercn-cli init drizzle-pg-starter

Example:

> npx servercn-cli init drizzle-pg-starter
 
√ Project root directory ... drizzle-starter
√ Select architecture » Feature (modules, shared)
√ Select package manager » npm
√ Initialize git repository? ... no

This creates a configured project with servercn.config.json:

{
  "$schema": "https://servercn.vercel.app/schema/servercn.config.json",
  "version": "1.1.11",
  "rootDir": "drizzle-starter",
  "packageManager": "npm",
  "runtime": "node",
  "language": "typescript",
  "framework": "express",
  "architecture": "mvc",
  "database": {
    "engine": "postgresql",
    "adapter": "drizzle"
  }
}

add

The add command installs a registry resource into your existing Servercn project.

It reads your servercn.config.json and resolves the correct implementation based on your selected stack (architecture, framework, database, ORM).


Add a Component

Use this to install reusable components such as utilities, middleware, or shared modules.

npx servercn-cli add <component-name>

Example:

npx servercn-cli add jwt-utils

Add a Foundation

Install a foundational layer that provides core system setup (e.g., base configs, global handlers, shared infrastructure).

npx servercn-cli add foundation <foundation-name>
npx servercn-cli add fd express-starter

This integrates the foundation according to your selected architecture and stack configuration.


Add Tooling

Install development tooling such as linters, formatters, logging utilities, or build integrations.

npx servercn-cli add tooling <tooling-name>
npx servercn-cli add tl prettier

Tooling is configured to match your runtime and language setup.


Add a Blueprint

Install a predefined feature structure that scaffolds a complete module pattern (routes, controller, service, model).

npx servercn-cli add blueprint <blueprint-name>
npx servercn-cli add bp stateless-auth

Blueprints accelerate feature-level development while preserving architectural consistency.


Add a Provider

Install a provider integration for external services, databases.

npx servercn-cli add provider <provider-name>
npx servercn-cli add pr mongodb-prisma

Add a Schema

Install a predefined database schema aligned with your selected database and ORM.

npx servercn-cli add schema <schema-name>
npx servercn-cli add sc auth/user

The schema is generated based on your configured database type and ORM.


install

Install dependencies for a registry item without scaffolding files. This command is useful for recovery, manual setup, or partial installs.

Usage:

npx servercn-cli install <type> <name> [options]

Alias

npx servercn-cli i <type> <name> [options]

Types:

| alias | full       |
|------ | ---------- |
| cp    | component  |
| bp    | blueprint  |
| pr    | provider   |
| sc    | schema     |
| tl    | tooling    |
| fd    | foundation |

Options

Install Modes (mutually exclusive)

--all         Install all dependencies (default)
--dev-only    Install only devDependencies
--deps-only   Install only runtime dependencies

Only one mode can be used at a time.

Example:

Install all dependencies (default)

npx servercn-cli i cp jwt-utils
npx servercn-cli i bp hybrid-auth
npx servercn-cli i pr mongodb-mongoose
npx servercn-cli i sc auth
npx servercn-cli i fd express-starter

Install only devDependencies

npx servercn-cli i cp jwt-utils --dev-only
npx servercn-cli i bp hybrid-auth --dev-only
npx servercn-cli i pr mongodb-mongoose --dev-only
npx servercn-cli i sc auth --dev-only
npx servercn-cli i fd express-starter --dev-only

Install only runtime dependencies

npx servercn-cli i cp jwt-utils --deps-only
npx servercn-cli i bp hybrid-auth --deps-only
npx servercn-cli i pr mongodb-mongoose --deps-only
npx servercn-cli i sc auth --deps-only
npx servercn-cli i fd express-starter --deps-only
npx servercn-cli i fd express-starter
 
Installing dependencies:
- express
- cors
- dotenv-flow
- cross-env
- helmet
- cookie-parser
- pino
- pino-pretty
- source-map-support
- zod
- swagger-autogen
- swagger-ui-express
 
Installing devDependencies:
- @types/express
- morgan
- @types/cors
- @types/morgan
- @types/cookie-parser
- @types/source-map-support
- @types/swagger-ui-express
 
 Successfully installed 12 dependencies
 
 Successfully installed 7 devDependencies

view

Inspect details of a registry item such as a component, blueprint, provider, or schema. This command helps you understand what will be installed, how it resolves, and what files are included—without making any changes.

Usage:

npx servercn-cli view <type> <name> [options]

Types:

| alias | full       |
|------ | ---------- |
| cp    | component  |
| bp    | blueprint  |
| pr    | provider   |
| sc    | schema     |
| tl    | tooling    |
| fd    | foundation |

Options

--json                Output result as JSON
--local               View local registry item (for testing)
--files               Show files with content
--fw <framework>      express | nestjs | nextjs
--arch <arch>         mvc | feature | modular | file-api
--db <database>       mongodb | mysql | postgresql
--orm <orm>           mongoose | prisma | drizzle
--variant <variant>   Variant key (for components)
--runtime <runtime>   node (default)

Examples

Basic usage

npx servercn-cli view cp async-handler
npx servercn-cli view cp async-handler --json
{
  "type": "component",
  "slug": "async-handler",
  "installation": "npx servercn-cli add async-handler",
  "runtime": "node",
  "framework": "express",
  "architecture": [
    "mvc",
    "feature"
  ],
  "dependencies": {
    "runtime": [],
    "dev": []
  },
  "env": [],
  "docs": "https://servercn.vercel.app/docs/express/components/async-handler",
  "schema": "https://servercn.vercel.app/sr/component/async-handler.json"
}

Component with variant and architecture

npx servercn-cli view cp oauth --variant=github --arch=mvc --json
{
  "type": "component",
  "slug": "oauth",
  "installation": "npx servercn-cli add oauth",
  "runtime": "node",
  "framework": "express",
  "architecture": "mvc",
  "variant": "github",
  "dependencies": {
    "runtime": [
      "dotenv-flow",
      "cross-env",
      "pino",
      "pino-pretty",
      "passport",
      "passport-github2"
    ],
    "dev": [
      "@types/passport-github2",
      "@types/passport"
    ]
  },
  "env": [
    "LOG_LEVEL",
    "GITHUB_CLIENT_ID",
    "GITHUB_CLIENT_SECRET",
    "GITHUB_REDIRECT_URI"
  ],
  "docs": "https://servercn.vercel.app/docs/express/components/oauth",
  "schema": "https://servercn.vercel.app/sr/component/oauth.json"
}

Variant option is only applicable when architecture is specified for components

list

List all available registry item commands.

npx servercn-cli list

list --json

Return registry item commands in JSON format.

npx servercn-cli ls --json
{
  "command": "npx servercn-cli list <type>",
  "types": [
    {
      "type": "component",
      "alias": "cp",
      "total": 24,
      "command": "npx servercn-cli list cp"
    },
    {
      "type": "blueprint",
      "alias": "bp",
      "total": 1,
      "command": "npx servercn-cli list bp"
    },
    {
      "type": "provider",
      "alias": "pr",
      "total": 11,
      "command": "npx servercn-cli list pr"
    },
    {
      "type": "foundation",
      "alias": "fd",
      "total": 4,
      "command": "npx servercn-cli list fd"
    },
    {
      "type": "tooling",
      "alias": "tl",
      "total": 6,
      "command": "npx servercn-cli list tl"
    },
    {
      "type": "schema",
      "alias": "sc",
      "total": 2,
      "command": "npx servercn-cli list sc"
    }
  ]
}

list --all

Return all registry items.

npx servercn-cli ls --all

list --all --json

Return all registry items in JSON structure.

npx servercn-cli ls --all --json

ls fd

List available all foundation.

npx servercn-cli ls fd
npx servercn-cli ls fd --json
{
  "type": "foundation",
  "command": "npx servercn-cli init <foundation-name>",
  "total": 4,
  "items": [
    {
      "name": "drizzle-mysql-starter",
      "command": "npx servercn-cli init drizzle-mysql-starter",
      "frameworks": [
        "express"
      ]
    },
    {
      "name": "drizzle-pg-starter",
      "command": "npx servercn-cli init drizzle-pg-starter",
      "frameworks": [
        "express"
      ]
    },
    {
      "name": "express-starter",
      "command": "npx servercn-cli init express-starter",
      "frameworks": [
        "express"
      ]
    },
    {
      "name": "mongoose-starter",
      "command": "npx servercn-cli init mongoose-starter",
      "frameworks": [
        "express"
      ]
    }
  ]
}

ls cp

Displays all reusable components available in the registry.

npx servercn-cli ls cp
npx servercn-cli ls cp --json

ls bp

Display all blueprints available in the servercn.

npx servercn-cli ls bp
npx servercn-cli ls bp --json

ls pr

Display all providers available in the servercn.

npx servercn-cli ls pr
npx servercn-cli ls pr --json

ls sc

Display all schema available in the servercn.

npx servercn-cli ls sc
npx servercn-cli ls sc --json

ls tl

Display all tooling available in the servercn.

npx servercn-cli ls tl
npx servercn-cli ls tl --json