@fluojs/platform-nodejs 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fluo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.ko.md ADDED
@@ -0,0 +1,90 @@
1
+ # @fluojs/platform-nodejs
2
+
3
+ <p><a href="./README.md"><kbd>English</kbd></a> <strong><kbd>한국어</kbd></strong></p>
4
+
5
+ fluo 런타임을 위한 raw Node.js HTTP 어댑터 패키지입니다.
6
+
7
+ ## 목차
8
+
9
+ - [설치](#설치)
10
+ - [사용 시점](#사용-시점)
11
+ - [빠른 시작](#빠른-시작)
12
+ - [주요 패턴](#주요-패턴)
13
+ - [공개 API 개요](#공개-api-개요)
14
+ - [관련 패키지](#관련-패키지)
15
+ - [예제 소스](#예제-소스)
16
+
17
+ ## 설치
18
+
19
+ ```bash
20
+ npm install @fluojs/platform-nodejs
21
+ ```
22
+
23
+ ## 사용 시점
24
+
25
+ Express나 Fastify와 같은 중간 프레임워크의 오버헤드 없이 Node.js 내장 `http` 또는 `https` 모듈에서 직접 fluo 애플리케이션을 실행하려는 경우에 사용합니다. 최소한의 리소스 사용, 저수준 최적화 또는 표준 Node API가 선호되는 환경에 이상적입니다.
26
+
27
+ ## 빠른 시작
28
+
29
+ ```typescript
30
+ import { createNodejsAdapter } from '@fluojs/platform-nodejs';
31
+ import { fluoFactory } from '@fluojs/runtime';
32
+ import { AppModule } from './app.module';
33
+
34
+ const app = await fluoFactory.create(AppModule, {
35
+ adapter: createNodejsAdapter({ port: 3000 }),
36
+ });
37
+
38
+ await app.listen();
39
+ ```
40
+
41
+ ## 주요 패턴
42
+
43
+ ### 서버 옵션 커스텀
44
+ 어댑터는 HTTPS 설정 및 바디 크기 제한을 포함한 표준 Node.js 서버 옵션을 수용합니다.
45
+
46
+ ```typescript
47
+ const adapter = createNodejsAdapter({
48
+ port: 443,
49
+ https: {
50
+ key: fs.readFileSync('key.pem'),
51
+ cert: fs.readFileSync('cert.pem'),
52
+ },
53
+ maxBodySize: '1mb',
54
+ });
55
+ ```
56
+
57
+ `maxBodySize`는 raw Node 요청 바디가 아직 스트리밍되는 동안 바로 강제되며, 부트스트랩 시 `multipart.maxTotalSize`를 따로 재정의하지 않으면 같은 값이 멀티파트 전체 페이로드 한도의 기본값으로도 사용됩니다.
58
+
59
+ ### 직접 애플리케이션 실행
60
+ `runNodejsApplication`을 사용하여 graceful shutdown 및 로깅이 포함된 보일러플레이트 없는 시작이 가능합니다.
61
+
62
+ 시그널 기반 종료가 `forceExitTimeoutMs`를 넘기거나 실패하면 헬퍼는 해당 상태를 로그와 `process.exitCode`로 보고하지만, 최종 프로세스 종료는 호스트 프로세스 소유자에게 맡깁니다.
63
+
64
+ ```typescript
65
+ import { runNodejsApplication } from '@fluojs/platform-nodejs';
66
+ import { AppModule } from './app.module';
67
+
68
+ await runNodejsApplication(AppModule, {
69
+ port: 3000,
70
+ globalPrefix: 'api',
71
+ });
72
+ ```
73
+
74
+ ## 공개 API 개요
75
+
76
+ - `createNodejsAdapter(options)`: raw Node.js HTTP 어댑터를 위한 기본 팩토리입니다.
77
+ - `bootstrapNodejsApplication(module, options)`: 리스너를 시작하지 않고 애플리케이션 인스턴스를 생성합니다.
78
+ - `runNodejsApplication(module, options)`: 생명주기 관리를 포함하여 애플리케이션을 부트스트랩하고 시작합니다.
79
+ - `NodejsHttpApplicationAdapter`: `createNodejsAdapter(...)`가 반환하는 어댑터 인스턴스를 설명하는 타입 전용 별칭이며, `@fluojs/runtime/node`가 공개하는 어댑터 surface를 그대로 보존합니다.
80
+
81
+ ## 관련 패키지
82
+
83
+ - `@fluojs/runtime`: 핵심 런타임 facade입니다.
84
+ - `@fluojs/websockets`: 실시간 게이트웨이 지원을 제공합니다.
85
+ - `@fluojs/http`: 공통 HTTP 추상화 및 데코레이터를 포함합니다.
86
+
87
+ ## 예제 소스
88
+
89
+ - `packages/platform-nodejs/src/index.test.ts`
90
+ - `examples/minimal/src/main.ts` (Fastify 기반이지만 구조적으로 유사함)
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @fluojs/platform-nodejs
2
+
3
+ <p><strong><kbd>English</kbd></strong> <a href="./README.ko.md"><kbd>한국어</kbd></a></p>
4
+
5
+ Raw Node.js HTTP adapter package for the fluo runtime.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [When to Use](#when-to-use)
11
+ - [Quick Start](#quick-start)
12
+ - [Common Patterns](#common-patterns)
13
+ - [Public API Overview](#public-api-overview)
14
+ - [Related Packages](#related-packages)
15
+ - [Example Sources](#example-sources)
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @fluojs/platform-nodejs
21
+ ```
22
+
23
+ ## When to Use
24
+
25
+ Use this package when you want to run a fluo application directly on the Node.js built-in `http` or `https` modules without the overhead of an intermediate framework like Express or Fastify. It is ideal for minimal footprints, custom low-level optimizations, or environments where standard Node APIs are preferred.
26
+
27
+ ## Quick Start
28
+
29
+ ```typescript
30
+ import { createNodejsAdapter } from '@fluojs/platform-nodejs';
31
+ import { fluoFactory } from '@fluojs/runtime';
32
+ import { AppModule } from './app.module';
33
+
34
+ const app = await fluoFactory.create(AppModule, {
35
+ adapter: createNodejsAdapter({ port: 3000 }),
36
+ });
37
+
38
+ await app.listen();
39
+ ```
40
+
41
+ ## Common Patterns
42
+
43
+ ### Customizing Server Options
44
+ The adapter accepts standard Node.js server options including HTTPS configuration and body size limits.
45
+
46
+ ```typescript
47
+ const adapter = createNodejsAdapter({
48
+ port: 443,
49
+ https: {
50
+ key: fs.readFileSync('key.pem'),
51
+ cert: fs.readFileSync('cert.pem'),
52
+ },
53
+ maxBodySize: '1mb',
54
+ });
55
+ ```
56
+
57
+ `maxBodySize` is enforced while the raw Node request body is still streaming, and the same limit becomes the default total multipart payload cap unless you override `multipart.maxTotalSize` during bootstrap.
58
+
59
+ ### Direct Application Execution
60
+ You can use `runNodejsApplication` for a zero-boilerplate startup that includes graceful shutdown and logging.
61
+
62
+ When signal-driven shutdown exceeds `forceExitTimeoutMs` or fails, the helper logs the condition and sets `process.exitCode`, but leaves final process termination to the host process owner.
63
+
64
+ ```typescript
65
+ import { runNodejsApplication } from '@fluojs/platform-nodejs';
66
+ import { AppModule } from './app.module';
67
+
68
+ await runNodejsApplication(AppModule, {
69
+ port: 3000,
70
+ globalPrefix: 'api',
71
+ });
72
+ ```
73
+
74
+ ## Public API Overview
75
+
76
+ - `createNodejsAdapter(options)`: Primary factory for the raw Node.js HTTP adapter.
77
+ - `bootstrapNodejsApplication(module, options)`: Creates an application instance without starting the listener.
78
+ - `runNodejsApplication(module, options)`: Bootstraps and starts the application with lifecycle management.
79
+ - `NodejsHttpApplicationAdapter`: Type-only alias describing the adapter instances returned by `createNodejsAdapter(...)`, while preserving the public adapter surface exported from `@fluojs/runtime/node`.
80
+
81
+ ## Related Packages
82
+
83
+ - `@fluojs/runtime`: The core runtime facade.
84
+ - `@fluojs/websockets`: Real-time gateway support.
85
+ - `@fluojs/http`: Shared HTTP abstractions and decorators.
86
+
87
+ ## Example Sources
88
+
89
+ - `packages/platform-nodejs/src/index.test.ts`
90
+ - `examples/minimal/src/main.ts` (Fastify-based, but structurally similar)
@@ -0,0 +1,11 @@
1
+ import { type NodeHttpAdapterOptions, type NodeHttpApplicationAdapter } from '@fluojs/runtime/node';
2
+ export { bootstrapNodeApplication as bootstrapNodejsApplication, runNodeApplication as runNodejsApplication, } from '@fluojs/runtime/node';
3
+ export type { BootstrapNodeApplicationOptions as BootstrapNodejsApplicationOptions, NodeApplicationSignal as NodejsApplicationSignal, NodeHttpAdapterOptions as NodejsAdapterOptions, NodeHttpApplicationAdapter as NodejsHttpApplicationAdapter, RunNodeApplicationOptions as RunNodejsApplicationOptions, } from '@fluojs/runtime/node';
4
+ /**
5
+ * Create the raw Node.js HTTP adapter exposed by `@fluojs/platform-nodejs`.
6
+ *
7
+ * @param options Transport-level Node.js settings such as port, retries, multipart, and HTTPS options.
8
+ * @returns The Node.js HTTP adapter instance used by the Fluo runtime.
9
+ */
10
+ export declare function createNodejsAdapter(options?: NodeHttpAdapterOptions): NodeHttpApplicationAdapter;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,wBAAwB,IAAI,0BAA0B,EACtD,kBAAkB,IAAI,oBAAoB,GAC3C,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,+BAA+B,IAAI,iCAAiC,EACpE,qBAAqB,IAAI,uBAAuB,EAChD,sBAAsB,IAAI,oBAAoB,EAC9C,0BAA0B,IAAI,4BAA4B,EAC1D,yBAAyB,IAAI,2BAA2B,GACzD,MAAM,sBAAsB,CAAC;AAE9B;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,sBAA2B,GACnC,0BAA0B,CAE5B"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { createNodeHttpAdapter } from '@fluojs/runtime/node';
2
+ export { bootstrapNodeApplication as bootstrapNodejsApplication, runNodeApplication as runNodejsApplication } from '@fluojs/runtime/node';
3
+ /**
4
+ * Create the raw Node.js HTTP adapter exposed by `@fluojs/platform-nodejs`.
5
+ *
6
+ * @param options Transport-level Node.js settings such as port, retries, multipart, and HTTPS options.
7
+ * @returns The Node.js HTTP adapter instance used by the Fluo runtime.
8
+ */
9
+ export function createNodejsAdapter(options = {}) {
10
+ return createNodeHttpAdapter(options);
11
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@fluojs/platform-nodejs",
3
+ "description": "Raw Node.js HTTP adapter package for the Fluo runtime.",
4
+ "keywords": [
5
+ "fluo",
6
+ "nodejs",
7
+ "node",
8
+ "http-adapter",
9
+ "platform",
10
+ "server"
11
+ ],
12
+ "version": "1.0.0-beta.1",
13
+ "private": false,
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/fluojs/fluo.git",
18
+ "directory": "packages/platform-nodejs"
19
+ },
20
+ "engines": {
21
+ "node": ">=20.0.0"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "type": "module",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ }
32
+ },
33
+ "main": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "dependencies": {
39
+ "@fluojs/http": "^1.0.0-beta.1",
40
+ "@fluojs/runtime": "^1.0.0-beta.1"
41
+ },
42
+ "devDependencies": {
43
+ "vitest": "^3.2.4"
44
+ },
45
+ "scripts": {
46
+ "prebuild": "node ../../tooling/scripts/clean-dist.mjs",
47
+ "build": "pnpm exec babel src --extensions .ts --ignore 'src/**/*.test.ts' --out-dir dist --config-file ../../tooling/babel/babel.config.cjs && pnpm exec tsc -p tsconfig.build.json",
48
+ "typecheck": "pnpm exec tsc -p tsconfig.json --noEmit",
49
+ "test": "pnpm exec vitest run -c vitest.config.ts",
50
+ "test:watch": "pnpm exec vitest -c vitest.config.ts"
51
+ }
52
+ }