@fcjs/cli
v1.0.0
Published
CLI for the FCJs framework
Maintainers
Readme
FCJs CLI
Official command-line interface for the First-class Js (FCJs) framework. Quickly scaffold projects and modules with best practices built-in.
Installation
npm install -g @fcjs/cliQuick Start
# Create a new FCJs project
fcjs project my-app
# Navigate to project
cd my-app
# Generate an HTTP module
fcjs module user
# Generate a WebSocket module
fcjs module chat --ws
# Generate middleware
fcjs middleware authCommands
fcjs project <project-name>
Creates a new FCJs project with:
- TypeScript configuration
- ESLint and Prettier setup
- Basic project structure
- Sample routes and middleware
- Package.json with FCJs dependencies
fcjs module <module-name> [--ws]
Generates a complete module with:
- Controller (HTTP or WebSocket)
- DTOs with Zod validation
- Service layer with CRUD operations
- Proper error handling
- TypeScript types
Options:
--ws- Generate WebSocket controller instead of HTTP
fcjs middleware <middleware-name>
Creates middleware with:
- FCJs middleware pattern
- Authorization header handling
- Token validation template
- Error handling with FCJs exceptions
Examples
HTTP Module
fcjs module productGenerates:
src/modules/product/product.controller.tssrc/modules/product/data-transfer-objects/product.dto.tssrc/modules/product/services/product.service.ts
WebSocket Module
fcjs module chat --wsGenerates WebSocket handlers for real-time communication.
Custom Middleware
fcjs middleware jwtGenerates authentication middleware with JWT validation template.
Project Structure
my-fcjs-project/
├── src/
│ ├── modules/
│ │ └── user/
│ │ ├── user.controller.ts
│ │ ├── data-transfer-objects/
│ │ │ └── user.dto.ts
│ │ └── services/
│ │ └── user.service.ts
│ ├── middlewares/
│ │ └── auth.middleware.ts
│ ├── routes/
│ │ └── index.ts
│ ├── index.ts
│ └── server.ts
├── package.json
└── tsconfig.jsonFramework Features
Generated code includes:
- Decorators:
@Route,@Get,@Post,@WsRoute,@WsMessage - Validation: Zod schemas with OpenAPI integration
- Error Handling: FCJs exception system
- Type Safety: Full TypeScript support
- API Documentation: Auto-generated OpenAPI specs
Contributing
Issues and pull requests welcome! See the GitHub repository.
License
MIT - see LICENSE file for details.
