Token导航 LogoToken导航TokenDH.com
前端设计敏感数据github未标认证来源可访问许可证需确认审计提醒

constructive-server-config建设性的服务器配置

Agent Skill

constructive-server-config 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

728

周安装

17

GitHub Stars

公开资料未说明

下载量

140
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:constructive-server-config(建设性的服务器配置)
来源仓库:https://github.com/constructive-io/constructive-skills
仓库路径:skills/constructive-server-config
安装命令:
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-server-config
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-server-config

简介

用于启动和管理 Constructive GraphQL API 服务器及 GraphiQL 探索器。

  • 支持多目标 API 路由配置(基于 header 或域名),便于微服务拆分。
  • 适用于代码生成、CI 集成测试和本地开发环境搭建。
  • 需预先部署 PostgreSQL 数据库并配置好 Constructive 实例。
  • constructive-server-config 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Constructive Server Configuration

How to run and configure the Constructive GraphQL API server, explorer, and codegen tools. The server exposes a multi-target GraphQL API with subdomain-based routing.

When to Apply

Use this skill when:

  • Starting the Constructive GraphQL server (cnc server)
  • Opening the GraphiQL explorer (cnc explorer)
  • Running code generation (cnc codegen)
  • Configuring API routing (header-based vs domain-based)
  • Running the server in CI for integration tests
  • Understanding the schema → PostGraphile → GraphQL pipeline

Prerequisites

  • PostgreSQL 17+ running with a deployed Constructive database (see pgpm skill — references/docker.md and references/env.md)
  • @constructive-io/cli installed (npm install -g @constructive-io/cli or available from the monorepo)
  • Database users bootstrapped via pgpm admin-users bootstrap --yes

The Constructive CLI (cnc)

The Constructive CLI (cnc or constructive) is the main entry point for running the platform.

Core Commands

CommandPurpose
cnc serverStart the GraphQL API server
cnc explorerStart the GraphiQL explorer UI
cnc codegenGenerate TypeScript types and SDK from the running API

Starting the Server

Quick Start

# Start with defaults
cnc server

# Start on a specific port with a specific database
PGDATABASE=constructive cnc server --port 5555

# Start with CORS wildcard (required for non-interactive / CI)
cnc server --origin '*'

# Start with explicit host, port, and origin
cnc server --host 0.0.0.0 --port 3000 --origin "*"

Important: The --origin option has no default. If omitted, the server will prompt interactively. Always pass --origin explicitly for non-interactive use (CI, Docker, scripts).

Server Options

OptionDescriptionDefault
--hostBind addresslocalhost
--portListen port5555
--originCORS allowed origin(interactive prompt)
--databaseDatabase name (or set PGDATABASE)(interactive prompt)
--simpleInflectionUse simple inflectiontrue
--oppositeBaseNamesUse opposite base namesfalse
--postgisEnable PostGIS extensiontrue
--servicesApiEnable Services API routingtrue
--cwdWorking directorycurrent directory

Environment Variables

The server reads its configuration from environment variables. Set these before starting:

Prerequisite: Ensure PG env vars are loaded (see pgpm skill, references/env.md) before starting the server.
# Required
export PGDATABASE=constructive

# API configuration
export API_IS_PUBLIC=true          # or false for admin mode
export API_EXPOSED_SCHEMAS=metaschema_public,services_public
export API_ANON_ROLE=anonymous     # Role for unauthenticated requests
export API_ROLE_NAME=authenticated # Role for authenticated requests
VariableDefaultDescription
PGHOSTlocalhostPostgreSQL host
PGPORT5432PostgreSQL port
PGUSERpostgresPostgreSQL user
PGPASSWORD(none)PostgreSQL password
PGDATABASE(prompt)Database name
API_IS_PUBLICtrue for public API, false for admin
API_EXPOSED_SCHEMASComma-separated schemas to expose
API_ANON_ROLERole for unauthenticated requests
API_ROLE_NAMERole for authenticated requests
API_ENABLE_SERVICESEnable services schema (admin only)
API_META_SCHEMASMeta schemas for routing
NODE_ENVdevelopmentEnvironment (affects CORS warnings)

Endpoints

The server uses subdomain-based routing via the Host header. For local development, *.localhost resolves to 127.0.0.1 automatically.

TargetEndpointDescription
Publichttp://api.localhost:<port>/graphqlPublic API (databases, tables, fields, schemas)
Authhttp://auth.localhost:<port>/graphqlAuthentication (sign-up, sign-in, tokens)
Objectshttp://objects.localhost:<port>/graphqlObject store (blobs, trees, commits)
Adminhttp://admin.localhost:<port>/graphqlAdmin operations

Health check: GET /healthz

API Routing Modes

Public Mode (API_IS_PUBLIC=true)

Uses domain-based routing. Each site/app gets its own subdomain:

https://myapp.example.com/graphql → routes to myapp's schemas
  • Used for external-facing APIs
  • API_ANON_ROLE=anonymous — unauthenticated users get minimal access
  • API_ROLE_NAME=authenticated — authenticated users get full access per RLS

Admin Mode (API_IS_PUBLIC=false)

Uses header-based routing. The client sends headers to select the target:

X-Api-Name: my_api
X-Database-Id: <uuid>
X-Meta-Schema: metaschema_public
  • Used for the Constructive admin UI
  • API_ANON_ROLE=administrator — admin users get full schema access
  • API_ENABLE_SERVICES=true — exposes the services schema for site/API management

Services API mode

When --servicesApi is true (default), the server enables the Constructive services routing layer, which routes requests based on the Host header subdomain to the correct schema/role combination. When false, it falls back to exposing raw PostgreSQL schemas.

GraphiQL Explorer

cnc explorer

Opens an interactive GraphiQL interface in the browser for testing queries against the running server. Useful for:

  • Exploring the generated schema
  • Testing queries and mutations
  • Debugging authentication and RLS policies

Code Generation

Using cnc codegen

cnc codegen

Generates TypeScript types and SDK code from the running GraphQL server. This is a convenience wrapper around @constructive-io/graphql-codegen.

Using graphql-codegen directly

For more control, use the codegen package directly:

npx @constructive-io/graphql-codegen --react-query --orm -e http://localhost:5555/graphql -o ./generated

See the constructive-graphql-codegen skill for full codegen documentation.

The Schema → GraphQL Pipeline

Understanding how database schemas become a GraphQL API:

PostgreSQL schemas (app_public, etc.)
        ↓
    PostGraphile v5 introspection
        ↓
    GraphQL schema (auto-generated)
        ↓
    cnc server (serves the API)
        ↓
    graphql-codegen (generates typed client)
        ↓
    React Query hooks / ORM / CLI

Key Concepts

  1. Schemas are the source of truth — tables, functions, views, and RLS policies in PostgreSQL define the API surface
  2. PostGraphile introspects automatically — no manual schema writing needed
  3. Smart naming — PostGraphile converts snake_case SQL to camelCase GraphQL automatically
  4. RLS is the auth layer — Row-Level Security policies in Postgres control what each user can access via GraphQL

Exposed Schemas

The API_EXPOSED_SCHEMAS variable controls which PostgreSQL schemas are exposed via GraphQL:

SchemaPurpose
metaschema_publicDatabase metadata (tables, fields, constraints, etc.)
services_publicService management (sites, APIs, domains, etc.)
constructive_auth_publicAuthentication (login, register, tokens)
app_public (custom)Application-specific tables and functions

Meta Schemas

API_META_SCHEMAS lists schemas used for schema validation and X-Meta-Schema routing:

API_META_SCHEMAS=metaschema_public,services_public,metaschema_modules_public,constructive_auth_public

Common Workflows

Start local dev server

Ensure PG env vars are loaded (see pgpm skill, references/env.md).
export PGDATABASE=constructive
cnc server --port 5555 --origin "*"

Verify the server is running

curl -s http://api.localhost:5555/graphql \
  -H 'Content-Type: application/json' \
  -d '{"query":"{ __typename }"}' | jq

Expected response:

{
  "data": {
    "__typename": "Query"
  }
}

Explore the API

# In another terminal
cnc explorer

Generate SDK from running server

npx @constructive-io/graphql-codegen \
  --react-query --orm \
  -e http://localhost:5555/graphql \
  -o ./src/generated

Use with the generated CLI

cd sdk/constructive-cli

# Create context pointing to local server
npx tsx cli/index.ts context create local \
  --publicEndpoint http://api.localhost:5555/graphql \
  --authEndpoint http://auth.localhost:5555/graphql \
  --objectsEndpoint http://objects.localhost:5555/graphql \
  --adminEndpoint http://admin.localhost:5555/graphql

npx tsx cli/index.ts context use local

Run admin and public servers together

# Terminal 1 — Admin server
API_IS_PUBLIC=false API_ENABLE_SERVICES=true \
  cnc server --port 3002 --origin "*"

# Terminal 2 — Public server
API_IS_PUBLIC=true \
  cnc server --port 3000 --origin "*"

CI / GitHub Actions

See github-workflows-pgpm for full CI patterns.
- name: Start cnc server
  run: |
    PGDATABASE=constructive cnc server --port 5555 --origin '*' &
    # Wait for server readiness
    for i in $(seq 1 30); do
      if curl -sf http://api.localhost:5555/graphql \
        -H 'Content-Type: application/json' \
        -d '{"query":"{ __typename }"}' > /dev/null 2>&1; then
        echo "Server is ready!"
        break
      fi
      if [ "$i" -eq 30 ]; then
        echo "Server failed to start after 30 seconds"
        exit 1
      fi
      sleep 1
    done

Server Architecture

The cnc server command:

  1. Reads PGDATABASE or prompts for database selection
  2. Collects configuration options (inflection, PostGIS, CORS, etc.)
  3. Calls GraphQLServer() from @constructive-io/graphql-server
  4. Starts an Express server with middleware for:

- Subdomain-based API routing (@constructive-io/url-domains) - JWT authentication - PostGraphile GraphQL engine - CORS handling (per-API or fallback) - Health check endpoint at /healthz

  1. Listens for PostgreSQL schema:update notifications to auto-flush caches

Source code:

  • constructive/packages/cli/src/commands/server.ts — CLI command handler
  • constructive/graphql/server/src/server.tsGraphQLServer class and factory

Troubleshooting

IssueCauseFix
Server hangs on startMissing --origin flagAdd --origin "*" for non-interactive mode
Port already in useAnother instance running`lsof -ti:5555 \xargs kill -9`
No schemas exposedAPI_EXPOSED_SCHEMAS not setSet the env var with comma-separated schema names
Auth errorsWrong role configurationCheck API_ANON_ROLE and API_ROLE_NAME
Can't connect to DBPG env vars not loadedSee pgpm skill (references/env.md) for loading database connection variables
Endpoints return 404Database not deployedDeploy with pgpm deploy --createdb --workspace --all --yes
GraphiQL shows empty schemaServer not running or wrong portVerify server is up and explorer points to correct URL
Subdomain routing not workingDNS issue*.localhost should resolve automatically; if not, add to /etc/hosts
CORS errors in browserWrong originPass --origin 'http://localhost:3000' or --origin '*'

References

  • Related skill: pgpm (references/docker.md) for PostgreSQL container management
  • Related skill: pgpm (references/env.md) for environment variable setup
  • Related skill: constructive-graphql-codegen for generating CLI from schema
  • Related skill: constructive-deployment for Docker Compose and production deployment

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.32%
按下载量换算49

Claude

28.99%
按下载量换算41

Cursor

20.87%
按下载量换算29

Gemini CLI

10.1%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills