
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
Node framework for Saber,base on Express
$ npm install rebas
var rebas = require('rebas');
var server = rebas(function (app) {
// 添加自定义处理器
...
});
// 启动服务器
server.start();
项目目录结构:
├──┬ config/ // server配置文件目录
│ ├─── app.json // 应用配置文件
│ ├─── rebas.json // Rebas框架配置文件
├─── dep/ // 前端第三方依赖
├─── lib/ // server开发工作目录
├─── logs/ // 日志文件
├─── node_modules/
├──┬ route/ // 路由配置文件件
│ ├─── config.json // 路由配置文件
├─── src/ // 前端开发工作目录
├──┬ tpl/ // 模版文件目录
│ ├─── config.json // 模版配置文件
├─── app.js // 服务器主入口
├─── edp-build-config.js
├─── edp-webserver-config.js
├─── index.html // 主框架页面
├─── module.conf
├─── package.json
应用配置文件,其中的信息会做为request的appConfig属性
框架配置文件,可省略,默认的配置如下:
{
"port": 8000, // 服务器端口号
"cluster": 0, // worker进程数,可以直接写'max',自动取最大值
"route": "route", // 路由配置文件目录
"template": "tpl", // 模版文件目录
"templateCommon": "tpl/common", // 公共模版文件目录
"action": "lib" // server开发工作目录
}
每个JSON文件存储Array类型的一个或者多个路由信息,每项路由信息为Object类型,必须包含以下字段:
{string} 路径{string} Action配置信息文件路径(相对于lib目录而言)例如以下的配置信息
{"path": "/", "action": "index"}
表示处理/请求的Action配置文件为lib/index.js
Action配置文件中可配置一个或者多个HTTP Methods对应的处理函数,目前支持的HTTP Methods有GET、POST、PUT、HEAD、DELETE、OPTIONS
每个HTTP Method对应的配置可以是一个function或者Array<function>,比如:
// 注意 这里代表HTTP Method的方法名是小写哟~
exports.get = function (req, res, next) {
// do business
...
};
其中处理函数的参数描述如下:
位于根目录的index.html,标准的HTML文件。使用占位符<!-- rebas:xxx -->方便渲染实际页面时插入动态数据。其中固有的占位符是<!-- rebas:content -->,表示后续渲染内容的插入位置,比如:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Startup News</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="/src/common/app.css">
<script src="http://s1.bdstatic.com/r/www/cache/ecom/esl/1-8-6/esl.js"></script>
<script>
// AMD Loader Configure
require.config({
...
});
</script>
</head>
<body>
<div id="viewport">
<!-- 默认的内容占位符 后续动态渲染的页面会插入此处 -->
<!-- rebas: content -->
</div>
<script>
// 启动前端代码
require(['app'], function (app) {
app.init();
});
</script>
</body>
</html>
创建Server实例
FAQs
Node runtime for Saber
The npm package rebas receives a total of 16 weekly downloads. As such, rebas popularity was classified as not popular.
We found that rebas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.