JSPM

  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q74159F
  • License MIT

CMMV core module for contract and application management

Package Exports

  • @cmmv/core
  • @cmmv/core/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@cmmv/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CMMV Logo

Contract-Model-Model-View (CMMV)
Building scalable and modular applications using contracts.

NPM Version Package License CircleCI

DocumentationReport Issue

Description

CMMV (Contract Model View) is a revolution in web application development, breaking paradigms and redefining how we create, maintain, and scale digital projects. Inspired by best practices and innovative concepts, CMMV integrates the power of contracts to automatically generate robust and secure structures, eliminating the complexity of manual code and providing an unprecedented development experience.

Imagine a platform where the definition of contracts in TypeScript becomes the heart of your application, automatically generating APIs, controllers, ORM entities, and even communication via binary RPC, all with optimized performance and seamless integration with the most modern technologies. With CMMV, you not only accelerate development, but also ensure the quality and consistency of your code, drastically reducing errors and rework.

In addition, CMMV offers a reactive and lightweight interface, based on Vue 3, but with the ability to support other frameworks such as React and Angular, always focusing on performance and SEO. With CMMV, the frontend is not just a presentation layer, but an integral and dynamic part of your application, synchronized in real time with the backend.

Whether you are an experienced developer or a programming newbie, CMMV empowers everyone to build powerful, scalable, modern systems by eliminating technical barriers and allowing creativity and innovation to be at the center of your development journey. It is more than a framework; it is a new way of thinking and building the future of web applications.

Philosophy

CMMV aims to simplify the development process by leveraging TypeScript's powerful type system and decorators. It eliminates the need for heavy frontend frameworks by focusing on direct control over data binding and interactions, while maintaining flexibility through modular design.

Features

  • Contract-Driven Development: Use TypeScript contracts to define models, controllers, and more.
  • Modular Architecture: Compose your application using modules, making it easy to manage and scale.
  • RPC & REST Support: Integrated support for both binary RPC via WebSocket and traditional REST APIs.
  • Express Integration: Seamless integration with Express for a familiar and robust HTTP server environment.
  • Extensible: Highly customizable and easy to extend with your own modules and components.

Setup with CLI

CMMV now provides a CLI (Command Line Interface) to streamline the installation process and quickly set up your project with the desired configurations.

To initialize a new project, you can use the following command:

$ pnpm dlx @cmmv/cli@latest create <project-name>

This command will walk you through a guided setup process, asking about your preferred configurations, such as enabling Vite, RPC, caching, repository type, and view setup (e.g., Vue 3 or Reactivity). It will automatically create the necessary files and folders, set up dependencies, and configure the project.

Legacy Setup (Manual)

If you prefer to set up the project manually, you can still install the necessary modules individually:

$ pnpm add @cmmv/core @cmmv/http @cmmv/view reflect-metadata class-validator class-transformer fast-json-stringify

Quick Start

Below is a simple example of how to create a new CMMV application:

import { Application } from "@cmmv/core";
import { DefaultAdapter, DefaultHTTPModule } from "@cmmv/http";
import { ViewModule } from "@cmmv/view";
import { ApplicationModule } from "./app.module";

Application.create({
    httpAdapter: DefaultAdapter,    
    modules: [
        DefaultHTTPModule,                
        ViewModule,        
        ApplicationModule
    ],
    services: [Repository],
    contracts: [...]
});

Features

🟢 Core

  • Application control, contract loading, models, and model generation
  • Base for creating transpilers
  • Core abstraction for HTTP, WS, contracts, and services
  • Base implementation for Singleton class
  • Contract, hook, metadata, and service decorators
  • Configuration validation and access control across all modules
  • Hooks system
  • Telemetry and logging
  • Base for creating registries

🔐 Auth

  • General application access control
  • Local user registration and login
  • Login via provider (Google, Facebook, etc.)
  • reCAPTCHA
  • Refresh token for session renewal
  • Full 2FA support with QR-Code generation and validation
  • Session control based on fingerprint, IP, and user agent

🚀 Cache

  • Optimized system responses using in-memory cache compatible with Redis, Memcached, MongoDB, or binary files
  • Simple integration decorators for controllers and gateways
  • Automatic integration with contracts
  • API for retrieving, updating, or removing cached data

🌐 HTTP

  • API availability via @cmmv/server or other adapters like Express
  • Automatic controller and service generation
  • Integration with @cmmv/cache and @cmmv/auth
  • Express Adapter
  • Fastify Adapter

📡 Protobuf

  • .proto file generation for RPC communication based on contracts
  • Generation of interfaces and type definitions for TypeScript
  • JSON contract generation for frontend usage
  • Contract interlinking

🗄 Repository

  • SQL, MySQL, PostgreSQL, SQL Server, Oracle, and MongoDB integration
  • Automatic entity creation for TypeORM
  • Auto-generation of indexes
  • Auto-generation of relationships
  • Data validation
  • CRUD operations for RPC and REST
  • Search filters (sorting, ID filtering, pagination)
  • Service overrides for direct repository integration
  • Integration with @cmmv/cache, @cmmv/auth

⏳ Scheduling

  • Decorators for scheduled task creation (cron)
  • Scheduled task management

🎨 View

  • SSR for SEO optimization
  • Dynamic templates similar to EJS
  • View engine compatible with Express
  • Internationalization support
  • Direct sub-view inclusion in HTML
  • Dynamic metadata handling (scripts, links, meta, header, title)
  • Bundled CSS and JavaScript compilation
  • Transparent RPC integration

🔄 WS (WebSocket)

  • Auto-generation of RPC communication gateways
  • Data packaging abstraction
  • WebSocket communication implementation for both client and server

🧩 Modules

  • Swagger: Provides API documentation with Swagger integration.
  • Testing: Now includes unit testing, S2S testing, and mocks.
  • Elastic: Elasticsearch integration for managing indices, documents.
  • Email: Email handling module using SMTP or AWS SES.
  • Encryptor: ECC-based encryption, AES-256-GCM
  • Events: Event-driven architecture for seamless communication
  • Inspector: Debugging and monitoring tools
  • Keyv: Key-value store integration using Keyv
  • Normalizer: Data transformation module for parsing (JSON, XML, YAML, CSV)
  • Queue: Manages job queues (Kafka, RabbitMQ, Redis)
  • UI: UI components for building dynamic applications
  • Vue: Enables integration with Vue.js