百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

flatiron

> 编程语言
开源

用于 Node.js 和浏览器的框架组件

1.3K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于 Node.js 和浏览器的框架组件

flatiron 用于 Node.js 和浏览器的框架组件 # HTTP 服务器示例: ```js

var flatiron = require('flatiron'), app = flatiron.app;

app.use(flatiron.plugins.http);

app.router.get('/', function () { this.res.writeHead(200, { 'Content-Type': 'text/plain' }); this.res.end('Hello world!\n'); });

app.start(8080); # HTTPS 服务器示例:js var flatiron = require('flatiron'), app = flatiron.app;

app.use(flatiron.plugins.http, { https: { cert: 'path/to/cert.pem', key: 'path/to/key.pem', ca: 'path/to/ca.pem' } });

app.router.get('/', function () { this.res.writeHead(200, { 'Content-Type': 'text/plain' }); this.res.end('Hello world!\n'); });

app.start(8080); # CLI 应用示例:js // example.js

var flatiron = require('flatiron'), app = flatiron.app;

app.use(flatiron.plugins.cli, { dir: __dirname, usage: [ 'This is a basic flatiron cli application example!', '', 'hello - say hello to somebody.' ] });

app.cmd('hello', function () { app.prompt.get('name', function (err, result) { app.log.info('hello '+result.name+'!'); }) })

app.start(); ## 运行它: % node example.js hello prompt: name: world info: hello world! ## 安装 # NPM (Node Package Manager) 安装 curl http://npmjs.org/install.sh | sh # Flatiron 安装 [sudo] npm install flatiron # Union 安装 (对于 `flatiron.plugins.http` 所需) npm install union # 使用: ## 使用 `flatiron.app`: `flatiron.app` 是一个 [broadway 注入容器](https://github.com/flatiron/broadway)。简要来说,它的作用是允许插件直接修改 `app` 对象:js var flatiron = require('flatiron'), app = flatiron.app;

var hello = { attach: function (options) { this.hello = options.message || 'Why hello!'; } };

app.use(hello, { message: "Hi! How are you?" });

// Will print, "Hi! How are you?" console.log(app.hello);


平铁中的几乎所有附加功能都来自 Broadway 插件,例如 `flatiron.plugins.http` 和 `flatiron.plugins.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言