Egg.js Web Framework

repository·next·Indexed 12 days ago

https://github.com/eggjs/egg

A professional-grade web framework for enterprise-scale applications featuring built-in process management, a robust plugin system, and high customizability. Includes core components such as @eggjs/core for application initialization and loading, @eggjs/cluster for process management, and @eggjs/cookies for encrypted cookie handling. Supports deployment to Cloudflare Workers and provides high-level APIs via EggLoader for loading controllers, middleware, and services.

Tokens
437.9K
Snippets
1.6K
Records
2K
Agent score
96%

What's inside Egg.js

  1. Overview of Egg Bundler

    next

    Egg Bundler (@eggjs/egg-bundler) is a developer tooling package used to produce deployable CommonJS artifacts from Egg applications. It serves two primary purposes:

    1. Node Startup Snapshots: Bundling applications for optimized Node.js startup.
    2. Tegg Standalone Service Workers: Bundling for Cloudflare Workers targets via StandaloneWorkerBundler.

    Important Constraints:

    • The underlying engine (PackRunner) uses @utoo/pack (powered by Turbopack).
    • The output is strictly CommonJS. There is no ESM output.
    • In single-file (export) mode, the output is an IIFE that ends with module.exports = factory(). This allows a Node require() to expose the entry's export default or named exports.
  2. Overview of @eggjs/router

    next
    The @eggjs/router package is the core routing component for the Egg.js framework. It is a fork of koa-router that includes additional features specifically tailored for Egg.js applications. It provides the mechanism to map incoming HTTP requests to specific handler functions based on URL patterns.
  3. Overview of Egg.js Features

    next

    Egg.js is a web framework designed for enterprise-level applications. Its core features include:

    • Built-in Process Management: Handles worker processes and lifecycle management.
    • Plugin System: Allows for modular extensions and easy integration of new capabilities.
    • Framework Customization: Provides hooks and structures to tailor the framework to specific needs.
    • Extensive Ecosystem: A large collection of community-driven plugins and framework integrations.
  4. Understand the @eggjs/core package purpose

    next

    The @eggjs/core package provides the fundamental runtime loader primitives required to assemble an Egg application. It manages the application lifecycle and provides the core abstractions used by other Egg runtime packages. Key components include:

    • Loaders: EggLoader, FileLoader, and ContextLoader for discovering and loading application components.
    • Lifecycle Management: Primitives to handle the application startup and shutdown phases.
    • Context: Base context classes that represent the request/response lifecycle.
    • Manifest Support: Mechanisms for handling application manifests.
  5. Egg.js Core Features

    next

    Egg.js is a professional web framework for Node.js that provides several core capabilities:

    • Built-in Multi-process Management: Handles process lifecycle and clustering out of the box.
    • Highly Extensible Plugin Mechanism: Allows for easy extension of framework functionality.
    • Deep Framework Customization: Provides hooks and structures for deep customization of the framework behavior.
    • Rich Ecosystem: Access to a wide variety of community-maintained plugins.
  6. Key features of Egg.js

    next

    Egg.js provides the following core capabilities:

    • Customizable Frameworks: Ability to build a specialized framework base on Egg.
    • Highly Extensible Plugin Mechanism: Modular architecture for adding functionality.
    • Built-in Cluster Support: Native support for clustering to improve performance and scalability.
    • Koa-based: Built on top of Koa for high performance.
    • Stable Core: A framework with high test coverage for enterprise reliability.
    • Progressive Development: Supports an incremental development workflow.
  7. Explore Egg.js community resources and tools

    next

    The Egg.js ecosystem includes various frameworks, development tools, and learning resources to assist with development and evaluation:

    Frameworks

    • aliyun-egg: A framework integration for Aliyun.

    Development Tools

    • vscode plugin - eggjs: Visual Studio Code extension for Egg.js.
    • vscode plugin - eggjs-dev-tools: Visual Studio Code extension for Egg.js development tools.

    Learning & Articles

    • awesome-egg: A curated list of Egg.js related projects and resources.
    • Zhihu Articles: Detailed evaluations and columns regarding Egg.js (e.g., "How to evaluate Ali's open source enterprise-level Node.js framework Egg?").
  8. Explore Egg.js Packages

    next

    Egg.js is composed of several specialized packages that form the runtime and development ecosystem:

    • @eggjs/core: Contains the Loader, lifecycle, and application core primitives.
    • Egg Bundler: Used for bundling Egg applications for Node startup snapshots and tegg standalone service workers.
    • Loader FS: A shared filesystem boundary for Egg loaders and future bundled runtimes.
    • Onerror Plugin: The default error-handling plugin providing a configurable response negotiation layer.
    • Standalone Service Worker: A runtime that serves HTTP controllers and MCP tools from a tegg module without requiring a full Egg application.
    • Typings: Provides the shared TypeScript type surface for cross-package Egg typings.
    • Utils: Shared utilities for module loading and bundled module-loader integration.
  9. Testing Tools used in Egg.js

    next

    Egg.js leverages the following tools for its testing ecosystem:

    • @eggjs/mock: Provides mocking utilities specifically for testing Egg.js applications.
    • vitest: The primary test runner, providing native TypeScript support (integrated via @eggjs/bin v8+).
    • supertest: An HTTP assertion library used for testing request/response cycles.
    • assert: The standard Node.js assertion library.
  10. Use @eggjs/tegg-types for shared types and enums

    next

    The @eggjs/tegg-types package provides shared types, interfaces, and enums used across the Egg.js ecosystem. It is intended for developers building Egg.js plugins or applications who need to ensure type compatibility with the core tegg packages.

    Use this package to access:

    • Shared types and enums used internally by multiple tegg core packages.
    • Shared types and enums specifically provided for tegg plugin and application development.