simple-boot-http-server-ssr

Server-Side Rendering framework integrating simple-boot-front and simple-boot-http-server

simple-boot-front와 simple-boot-http-server를 통합한 서버 사이드 렌더링 프레임워크

GitHubNPM

Installation

Create a new SSR project or install the package

새 SSR 프로젝트를 생성하거나 패키지를 설치하세요

Demo example

DEMO EXAMPLE

데모 예제

Architecture Overview

Understanding simple-boot-http-server-ssr's SSR architecture

simple-boot-http-server-ssr의 SSR 아키텍처 이해하기

Core SSR Architecture

Server-side rendering with JSDOM and component pooling

JSDOM과 컴포넌트 풀링을 사용한 서버 사이드 렌더링

graph TB
    A[SimpleBootHttpSSRServer] -->|Extends| B[SimpleBootHttpServer]
    A -->|Uses| C[SSRFilter]
    A -->|Uses| D[IntentSchemeFilter]
    
    C -->|Creates| E[JSDOM Pool]
    C -->|Manages| F[SimpleBootFront Pool]
    
    E -->|Virtual DOM| G[Window/Document]
    F -->|Renders| H[Components]
    
    D -->|Handles| I[Intent API Calls]
    I -->|Proxies| J[Server Services]
    
    K[Client] -->|HTTP Request| A
    A -->|SSR HTML| K
    K -->|Hydrates| L[Client App]
    
    style A fill:#e1f5ff
    style C fill:#dcfce7
    style D fill:#fef3c7
    style E fill:#ffe4e6
    style F fill:#f3e8ff
    linkStyle default stroke:#aaaaaa,stroke-width:2px

SSR Request Lifecycle

How server-side rendering processes requests

서버 사이드 렌더링이 요청을 처리하는 방식

sequenceDiagram
    participant Client
    participant Server as HTTP Server
    participant SSR as SSRFilter
    participant Pool as Front Pool
    participant JSDOM
    participant App as SimpleBootFront

    Client->>Server: GET /page
    Server->>SSR: proceedBefore()
    SSR->>Pool: dequeue()
    Pool->>App: Get available instance
    
    App->>App: Set ssrUse = true
    App->>JSDOM: Navigate to /page
    JSDOM->>App: goRouting()
    App->>App: Render components
    App->>App: Execute lifecycle hooks
    
    App->>SSR: Return HTML
    SSR->>SSR: Inject server_side_data
    SSR->>Client: Send rendered HTML
    
    SSR->>Pool: enqueue()
    Pool->>Pool: Recycle instance
    
    Client->>Client: Hydrate with data

Intent Scheme Communication

Client-server RPC using Symbol-based intent scheme

Symbol 기반 인텐트 스킴을 사용한 클라이언트-서버 RPC

sequenceDiagram
    participant Client as Client Service
    participant Proxy as SymbolIntentApiServiceProxy
    participant HTTP as HTTP Request
    participant Filter as IntentSchemeFilter
    participant Intent as IntentManager
    participant Server as Server Service

    Client->>Proxy: call method(args)
    Proxy->>Proxy: Extract Symbol
    Proxy->>HTTP: POST with Intent header
    
    HTTP->>Filter: X-Simple-Boot-Ssr-Intent-Scheme
    Filter->>Intent: Publish intent
    Intent->>Server: Execute method
    Server->>Intent: Return result
    
    Intent->>Filter: Result data
    Filter->>HTTP: JSON response
    HTTP->>Proxy: Parse response
    Proxy->>Client: Return result

Data Hydration Flow

Server data serialization and client hydration

서버 데이터 직렬화 및 클라이언트 하이드레이션

sequenceDiagram
    participant Server as Server Render
    participant Save as SaveAroundAfter
    participant HTML
    participant Client as Client App
    participant Load as LoadAroundBefore

    Server->>Server: Execute service method
    Server->>Save: Store result
    Save->>Save: JSON.stringify(data)
    Save->>HTML: window.server_side_data
    
    HTML->>Client: Delivered HTML
    Client->>Client: Start hydration
    Client->>Load: Check cached data
    Load->>Load: Parse server_side_data
    
    alt Data found
        Load->>Client: Return cached data
        Client->>Client: Skip API call
    else No data
        Client->>Client: Execute API call
    end

Getting Started

Quick start with SSR server setup

SSR 서버 설정으로 빠르게 시작하기

Basic SSR Server

Create a minimal SSR server with front-end integration

프론트엔드 통합을 포함한 최소 SSR 서버 생성

SSR Factory

Create factory to bootstrap SimpleBootFront instances

SimpleBootFront 인스턴스를 부트스트랩하는 팩토리 생성

Factory Implementation

Custom factory for creating front-end applications

프론트엔드 애플리케이션 생성을 위한 커스텀 팩토리

Shared Services

Create services that work on both server and client

서버와 클라이언트 모두에서 작동하는 서비스 생성

Service Interface

Define service contract with Symbol for identification

식별을 위한 Symbol로 서비스 계약 정의

Server-Side Service

Implement service on server with actual logic

실제 로직으로 서버에서 서비스 구현

Client-Side Service Proxy

Client service that proxies calls to server

서버 호출을 프록시하는 클라이언트 서비스

Using Services in Components

Inject and use services transparently

서비스를 투명하게 주입 및 사용

Intent Scheme Filter

RPC communication using custom HTTP headers

커스텀 HTTP 헤더를 사용한 RPC 통신

IntentSchemeFilter Setup

Enable Symbol-based RPC between client and server

클라이언트와 서버 간 Symbol 기반 RPC 활성화

Data Hydration

Optimize performance with server data caching

서버 데이터 캐싱으로 성능 최적화

SaveAroundAfter Decorator

Save server-side data for client hydration

클라이언트 하이드레이션을 위한 서버 사이드 데이터 저장

LoadAroundBefore Decorator

Load hydrated data on client to skip API calls

API 호출을 건너뛰기 위해 클라이언트에서 하이드레이트된 데이터 로드

JSDOM Integration

Virtual DOM environment for server-side rendering

서버 사이드 렌더링을 위한 가상 DOM 환경

JsdomInitializer

Set up JSDOM with global polyfills

글로벌 폴리필로 JSDOM 설정

Component Pool Management

Efficient handling of concurrent SSR requests

동시 SSR 요청의 효율적 처리

Pool Configuration

Configure pool size and behavior

풀 크기 및 동작 구성

Complete SSR Application

Full working example with all features

모든 기능을 포함한 완전한 작동 예제

Complete Server Setup

Production-ready SSR server configuration

프로덕션 준비 SSR 서버 구성