egg-core

Explain Egg.js module architecture and dependency injection with decorators.

19.0k|1.8k|Updated Jun 18, 2016
One-click install
npx skills add https://github.com/eggjs/egg --skill egg-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: egg-core
Source: https://github.com/eggjs/egg/tree/main/packages/skills/egg-core
Command: npx skills add https://github.com/eggjs/egg --skill egg-core

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and effectively use the core concepts of the Egg.js framework, including its module system, dependency injection, and object lifecycle management.

Core Features & Use Cases

  • Module System: Learn how to define and organize code into modules.
  • Dependency Injection: Understand and utilize @Inject, @SingletonProto, and @ContextProto decorators.
  • Object Lifecycle: Manage the creation and destruction of objects throughout the application's life.
  • Use Case: A new developer joining an Egg.js project can use this Skill to quickly grasp how services are structured, how they depend on each other, and how to correctly implement new features within the framework's architecture.

Quick Start

Explain how to define a new module in Egg.js.

Frequently Asked Questions about egg-core

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does dependency injection work in Egg.js?

Dependency injection in Egg.js uses decorators like @Inject, @SingletonProto, and @ContextProto to manage object lifecycle and dynamically resolve dependencies within the module system.

What is the difference between @SingletonProto and @ContextProto in Egg.js?

@SingletonProto creates a single object instance for the application lifecycle, while @ContextProto creates a new instance for each request context, controlling object lifecycle in Egg.js.

How do I define a new module in Egg.js?

To define a new module in Egg.js, you organize code into modular structures and utilize the framework's module system to manage dependencies and object lifecycle effectively.

Can I dynamically select implementations at runtime in Egg.js?

Yes, Egg.js supports runtime multi-implementation selection through its dynamic injection mechanisms, allowing you to choose specific implementations dynamically during application execution.

Does Egg.js support TypeScript for module architecture?

Yes, Egg.js supports TypeScript, allowing you to define module architecture and utilize decorators for dependency injection and context management within TypeScript environments.