simple-boot-http-server

A lightweight and powerful HTTP web server framework for Node.js

Node.js를 위한 경량 고성능 HTTP 웹 서버 프레임워크

GitHubNPM

Installation

Create a new server or install the package

새 서버를 생성하거나 패키지를 설치하세요

Demo example

DEMO EXAMPLE

데모 예제

Architecture Overview

Understanding simple-boot-http-server's architecture

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

Core Architecture

Request/Response lifecycle with filters and endpoints

필터와 엔드포인트를 사용한 요청/응답 생명주기

graph TB
    A[SimpleBootHttpServer] -->|Extends| B[SimpleApplication]
    A -->|Creates| C[HTTP/HTTPS Server]
    A -->|Manages| D[SessionManager]

    B -->|DI Container| E[SimstanceManager]
    B -->|Routing| F[RouterManager]

    C -->|Request| G[RequestResponse]
    G -->|Through| H[Request EndPoints]
    H -->|Through| I[Filters Chain]
    I -->|Executes| J[Router Methods]
    J -->|Through| K[Filters After]
    K -->|Through| L[Close EndPoints]

    M[GlobalAdvice] -->|Catches| N[Exceptions]

    style A fill:#e1f5ff
    style B fill:#fff4e6
    style C fill:#dcfce7
    style G fill:#fef3c7
    style I fill:#ffe4e6
    linkStyle default stroke:#aaaaaa,stroke-width:2px

Request Processing Flow

How HTTP requests are processed through the pipeline

HTTP 요청이 파이프라인을 통해 처리되는 방식

sequenceDiagram
    participant Client
    participant Server as HTTP Server
    participant RR as RequestResponse
    participant EP as Request EndPoints
    participant F as Filters
    participant R as Router
    participant CEP as Close EndPoints

    Client->>Server: HTTP Request
    Server->>RR: Create RequestResponse
    RR->>EP: onInit lifecycle
    EP->>EP: Log request start
    EP->>F: proceedBefore()

    alt Filter allows
        F->>R: Route to method
        R->>R: Execute handler
        R->>F: proceedAfter()
        F->>Client: Send response
    else Filter blocks
        F->>Client: Early response
    end

    Server->>CEP: on close event
    CEP->>CEP: Log duration

Routing System

Decorator-based routing with HTTP methods

HTTP 메서드를 사용한 데코레이터 기반 라우팅

graph LR
    A[Router Decorator] --> B[AppRouter]
    B --> C[ApiRouter path=/api]
    B --> D[Other Routers]

    C --> E[GET /api/hello]
    C --> F[GET /api/users]
    C --> G[POST /api/users]
    C --> H[GET /api/time]

    E --> I[hello method]
    F --> J[getUsers method]
    G --> K[createUser method]
    H --> L[getTime method]

    style A fill:#e1f5ff
    style B fill:#dcfce7
    style C fill:#fef3c7
    linkStyle default stroke:#aaaaaa,stroke-width:2px

Session Management

Built-in session with auto-cleanup

자동 정리 기능이 있는 내장 세션

sequenceDiagram
    participant Client
    participant Server
    participant SM as SessionManager
    participant Store as Session Store

    Client->>Server: First Request
    Server->>SM: session()
    SM->>SM: Generate UUID
    SM->>Store: Create session
    Server->>Client: Set-Cookie: sessionId

    Client->>Server: Subsequent Request
    Server->>SM: session(uuid)
    SM->>Store: Get session data
    SM->>SM: Check expiration

    alt Not expired
        SM->>Server: Return session
    else Expired
        SM->>Store: Delete old data
        SM->>Store: Create new session
    end

    Note over SM: Auto cleanup every interval
    SM->>Store: Check all sessions
    SM->>Store: Delete expired

Getting Started

Quick start with basic server setup

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

Basic HTTP Server

Create a minimal HTTP server

최소 HTTP 서버 생성

Routing

Declarative routing with HTTP method decorators

HTTP 메서드 데코레이터를 사용한 선언적 라우팅

Root Router Setup

Create root router with nested routers

중첩 라우터로 루트 라우터 생성

HTTP Method Decorators

Map HTTP methods to controller methods

HTTP 메서드를 컨트롤러 메서드에 매핑

Services

Services

Injectable services with dependency injection

의존성 주입을 사용한 주입 가능한 서비스

User Service Example

Create and inject services in routers

라우터에서 서비스 생성 및 주입

EndPoints

EndPoints

Hook into request lifecycle events

요청 생명주기 이벤트에 훅

Request EndPoint

Execute code when request starts

요청 시작 시 코드 실행

Close EndPoint

Execute code when request completes

요청 완료 시 코드 실행

Global Advice

Global Advice

Centralized exception handling for all routes

모든 라우트에 대한 중앙 집중식 예외 처리

Exception Handler

Catch and handle all exceptions globally

모든 예외를 전역적으로 포착 및 처리

Error Handling

Error Handling

Built-in HTTP error classes

내장 HTTP 에러 클래스

HTTP Errors

Pre-defined error classes for common HTTP status codes

일반적인 HTTP 상태 코드를 위한 사전 정의된 에러 클래스

Available Error Classes

Complete list of built-in HTTP error classes

내장 HTTP 에러 클래스의 전체 목록

Session Management

Session Management

Built-in session support with customizable storage

커스터마이징 가능한 스토리지를 포함한 내장 세션 지원

Using Sessions

Store and retrieve data in user sessions

사용자 세션에 데이터 저장 및 검색

Session Configuration

Configure session behavior and storage

세션 동작 및 스토리지 구성

Request/Response API

Request/Response API

RequestResponse abstraction for HTTP operations

HTTP 작업을 위한 RequestResponse 추상화

Request API

Access request data easily

요청 데이터에 쉽게 접근

Response API

Send responses with control

제어와 함께 응답 전송

HTTPS Support

HTTPS Support

Run secure HTTPS server with SSL/TLS

SSL/TLS로 안전한 HTTPS 서버 실행

HTTPS Server

Configure HTTPS with certificate files

인증서 파일로 HTTPS 구성