Skip to content
LykosJSLYKOSJS
CreatorDeveloperBenchmarkshomeGet started
v1.0.0
Modular architectureDependency injectionCLI generatorsWebSockets
PREVIOUSDependency injectionNEXT WebSockets
© 2026 LykosJS · MIT LicenseBun · TypeScript

© 2026 LykosJS. Released under the MIT License.
Built by Zen Allaham.

DocsGitHubX
DOCS/V1.0.0/DEVELOPER TOOLS
DEVELOPER TOOLS

CLI generators

Scaffold REST and GraphQL applications, detect project templates automatically, and generate feature modules with the LykosJS CLI.

Overview

LykosJS provides a dedicated command-line interface (CLI) to streamline project setup and feature development. It includes project scaffolding and module generators for both REST and GraphQL applications.

The CLI automatically detects the current project's template and selects the appropriate module generator. You do not need to specify REST or GraphQL when generating a module.

LykosJS command-line interface

Create a project

Start a new LykosJS application using Bun:

bash
1bun create lykosjs my-app

During project creation, select the API architecture you want to use:

  • REST API: A controller and router-based application with validation rules.
  • GraphQL: A schema-first application organized around GraphQL schemas and resolvers.

The CLI provides an interactive selection interface. You can navigate using the arrow keys, j and k,Tab, or 1 and 2, then confirm with Enter. Press Esc orCtrl+C to cancel.

Generate a module

Generate a feature module inside an existing LykosJS project:

bash
1bun run lykosjs g module users

You can also use the full command:

bash
1bun run lykosjs generate module users

The CLI detects the project template and automatically invokes the corresponding generator.

Automatic project detection

LykosJS identifies the project type by reading thepackage.json file in the current working directory. GraphQL projects contain a template marker:

json
1{2  "lykosAPI": {3    "template": "graphql"4  }5}

If the marker is set to "graphql", the GraphQL generator is selected. Otherwise, the project is treated as REST, including projects created before this marker was introduced.

Automatic fallback
If package.json is missing, unreadable, or does not contain the GraphQL marker, the CLI defaults to the REST generator.

REST module generator

For REST projects, the generator creates a feature directory under src/modules. It generates controllers, routers, modules, schemas, validation rules, and tests.

Before generating the files, the CLI asks whether you want to include a service:

bash
1? Do you want to generate a Service?2❯ Yes3  No4↑/↓ to move · enter to select · esc to cancel

Selecting Yes generates a service and connects it to the controller through constructor injection. SelectingNo generates the controller without a service.

The REST generator produces the following structure when service generation is enabled:

text
1src/modules/users/2├── users.service.ts3├── users.controller.ts4├── users.route.ts5├── users.module.ts6├── schemas/7│   └── user.schema.ts8├── rules/9│   ├── create.ts10│   └── update.ts11└── tests/12    ├── users.controller.test.ts13    └── users.service.test.ts

When service generation is disabled, the service file and service test are omitted. The remaining REST module files are still generated.

Generated REST components

  • Controller: Provides the request handlers for creating, retrieving, updating, and deleting resources.
  • Router: Registers REST endpoints and separates public routes from routes protected by authentication middleware.
  • Module: Registers the generated controller and router using LykosJS dependency injection.
  • Service: Provides a starting point for business logic when service generation is enabled.
  • Schema: Creates a schema file for the singular resource name.
  • Rules: Creates separate files for create and update validation rules.
  • Tests: Generates basic Bun test files for the controller and, optionally, the service.
Generated authentication
The generated REST controller includes averifyToken() placeholder, while the module configures Bearer authentication throughdefineAuth(). Implement token verification before relying on protected routes.

GraphQL module generator

For GraphQL projects, the CLI uses a dedicated schema-first generator. It creates a GraphQL schema, resolver, service, module, and test files.

Unlike the REST generator, GraphQL module generation does not ask whether to create a service. The service is always included.

bash
1bun run lykosjs g module posts

Example generated structure:

text
1src/modules/posts/2├── graphql-schema/3│   └── posts.graphql4├── posts.module.ts5├── posts.service.ts6├── posts.resolver.ts7└── tests/8    ├── posts.service.test.ts9    └── posts.resolver.test.ts

Generated GraphQL components

  • GraphQL schema: Defines the resource type, create and update inputs, queries, and mutations.
  • Resolver: Exposes query and mutation handlers and delegates operations to the service.
  • Service: Provides methods for creating, retrieving, updating, and deleting resources.
  • Module: Registers the service and resolver usingbind().
  • Tests: Creates separate test files for the resolver and service.

The generated schema includes list and single-resource queries, along with create, update, and delete mutations. The generated resolver delegates these operations to the corresponding service methods.

Module naming conventions

Module names must start with a letter and contain only letters, numbers, hyphens, or underscores. Names are normalized into kebab-case for directories and filenames, and PascalCase for generated class names.

bash
1bun run lykosjs g module users2bun run lykosjs g module billing-events3bun run lykosjs g module user_profiles

For GraphQL modules, the generator also derives singular and plural names for schema types and query fields. Use a plural resource name when generating a GraphQL module, so the CLI can derive distinct singular and plural forms.

bash
1# Valid example2bun run lykosjs g module posts3 4# Invalid for GraphQL generation:5bun run lykosjs g module post

File safety

Before writing files, the generators check whether any target file already exists. If a conflict is found, generation stops with an error instead of overwriting existing files.

If an error occurs while writing generated files, the CLI attempts to remove files created during that generation operation.

Existing files are preserved
The generators use exclusive file creation and do not intentionally overwrite existing files. Review conflicting files before running the command again.

CLI commands

Use the following commands to access the CLI:

bash
1# Show available commands2bun run lykosjs --help3 4# Generate a module5bun run lykosjs g module users6 7# Alternative command syntax8bun run lykosjs generate module users9 10# Display CLI version information11bun run lykosjs --version

The CLI also supports -h as an alias for--help, and -v as an alias for--version.

REST and GraphQL use different generators
The project template determines the generated architecture. REST modules use controllers and routers, while GraphQL modules use schemas and resolvers. Make sure you run the command from the intended project directory.