MidwayJS Framework

repository·v4-next·Indexed 26 days ago

https://github.com/midwayjs/midway

A web framework for complex Node.js applications. It includes a variety of sub-packages and components such as @midwayjs/api-bridge for shared client runtimes, @midwayjs/serverless-fc-starter for Alibaba Cloud Function Compute, and integrations for Axios, Busboy, etcd, and Tencent Cloud Object Storage (COS). The framework provides tools for CORS and JSONP configuration via @midwayjs/cross-domain, session management via @midwayjs/express-session, and serverless HTTP parsing via @midwayjs/serverless-http-parser.

Tokens
393K
Snippets
1.2K
Records
2.2K
Agent score
92%

What's inside MidwayJS

  1. Overview of Midway FaaS

    v4-next

    Midway FaaS is a Serverless framework designed for building Node.js cloud functions. It is intended to reduce maintenance costs and allow developers to focus on product development in cloud-native environments.

    Key features include:

    • Cross-cloud vendor support: Deploy the same code across multiple cloud platforms to avoid vendor lock-in.
    • Code reuse: Leverages Midway's dependency injection capability to allow logical units to be reused and combined into complex applications.
    • Traditional Migration: Supports seamless migration of traditional applications (such as Egg.js, Koa, and Express.js) to various cloud function providers through runtime scalability.
  2. Overview of Midway Components

    v4-next

    A Component in Midway is a reusable, multi-framework module package. Components are used to:

    1. Wrap downstream code: Simplify the use of third-party modules (e.g., ORMs, Swagger).
    2. Encapsulate reusable business logic: Abstract common Controllers, Services, etc.

    Components can be loaded locally or published as npm packages. They are compatible with Midway v3 and Serverless. Most Midway capabilities—including configuration, lifecycle, controllers, and interceptors—can be utilized within a component. When designing components, it is recommended to depend primarily on @midwayjs/core to ensure compatibility across different framework scenarios.

  3. Getting Started with Midway.js

    v4-next

    Midway.js is a modern Node.js framework designed for building web applications. This tutorial introduces the core concepts of the framework, including building controllers for HTTP requests, using services for business logic, and leveraging Dependency Injection (DI) and Decorators to manage application components.

    The tutorial's tech stack includes:

    • TypeScript for type safety
    • Koa as the underlying web framework (via @midwayjs/koa)
    • Dependency Injection for modularity
    • Decorators for declarative programming
  4. Introduction to Midway Hooks Full-stack Solution

    v4-next

    Midway Hooks is a functional full-stack framework based on Midway. It provides an integrated development experience by adding a frontend adaptation layer on top of standard Midway projects. This allows developers to maintain both frontend and Node.js code within the same project, enabling seamless collaboration between the two.

    Note: The integrated solution is gradually entering maintenance mode. Existing projects can continue to use it, but new projects should choose with caution.

  5. Overview of Midway.js Core Concepts and Learning Path

    v4-next

    The Midway.js tutorial is structured into five parts covering the full lifecycle of application development:

    • Part 1: Creating Applications: Project structure, @Controller decorators, routing, and request parameter handling (@Query, @Param, @Body).
    • Part 2: Dependency Injection & Services: Using @Provide to define services and @Inject to perform dependency injection via the IoC container.
    • Part 3: Request & Response Handling: Implementing RESTful APIs with @Post, @Put, and @Del decorators, and managing errors using MidwayHttpError and global error filters.
    • Part 4: Middleware & Configuration: Implementing middleware with the @Middleware decorator and managing multi-environment configurations using the @Config decorator.
    • Part 5: Data Validation & Best Practices: Using @midwayjs/validate with the @Rule decorator for request validation and following architectural best practices.
  6. Overview of MidwayJS

    v4-next

    Midway is a Node.js framework written in TypeScript designed for building Serverless services, traditional server-side applications, microservices, and small programs. It utilizes an IoC (Inversion of Control) injection mechanism to decouple business logic, facilitating the development of large-scale Node.js applications.

    Key capabilities include:

    • Support for various web frameworks: Koa, Express, or EggJS.
    • Built-in solutions for Socket.io, gRPC, Dubbo.js, and RabbitMQ.
    • Serverless compatibility with AWS, Alibaba Cloud, and Tencent Cloud.
    • Integration with modern front-end frameworks like React and Vue.
  7. Overview of Midway.js tutorial curriculum

    v4-next

    The Midway.js interactive tutorial is structured into 5 parts covering 17 lessons:

    • Part 1: Creating Applications: Project structure, creating your first Controller, and handling request parameters.
    • Part 2: Dependency Injection & Service: Creating Services and using Dependency Injection (DI).
    • Part 3: Request & Response Handling: Handling POST requests and error handling.
    • Part 4: Middleware & Configuration: Middleware basics and application configuration management.
    • Part 5: Data Validation & Best Practices: Data validation and industry best practices.