Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@rockerjs/dao
Advanced tools
安装 Node.js(v8.9.3+)
安装 vbuilder 命令行
[sudo] npm i @vdian/vbuilder-cli --registry http://npm.idcvdian.com
进入项目目录(名称任意)
mkdir rocker-mvc-project
cd rocker-mvc-project
执行命令 v
,根据提示依次完成:项目初始化、启动本地开发环境
项目初始化完成后,也可以执行 npm run dev
启动本地开发环境
npm run dev
所有 API 挂载在引入的 MVC 对象下,而且可以串行调用
MVC.route({
'/home': import('./home')
}).start()
接收参数:
- { port: number }
在添加路由以及中间件后启动服务
MVC.pipe(middleWare).route({ }).start()
接收参数:
- RouterMap => { [index: string]: Function } | { [index: string]: Promise };
- RouterRegType => { all: RouterMap, render?: { start: string, end: string } }
为应用添加路由处理方法,参数示例如下:
// 1. RouterMap
MVC.route({
'/home': import('./home'),
'/about': import('./about')
})
// 2. RouterRegType
// 为所有的路由添加公有的 header 和 footer 脚本
MVC.route({
all: {
'/home': import('./home'),
'/about': import('./about')
},
render: {
start: './header.ejs',
end: './footer.ejs'
}
})
接收参数:
- Koa 中间件
Rocker MVC 可以任意使用Koa的中间件,示例如下:
编写 logRequest 中间件
function log( ctx ) {
console.log( ctx.method, ctx.header.host + ctx.url )
}
export default function () {
return async function ( ctx, next ) {
log(ctx);
await next()
}
}
通过 pipe 来引入中间件
import logRequest from './logRequest'
MVC.pipe(logRequest()).route({ }).start()
全局安装 typescript 编译器
npm i -g typescript
编写 ts 配置文件 tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": false,
"allowJs": true,
"inlineSourceMap": true
},
"exclude": [
"node_modules",
"coverage"
]
}
执行编译操作
tsc .
FAQs
Database access object framework, support transaction
The npm package @rockerjs/dao receives a total of 1 weekly downloads. As such, @rockerjs/dao popularity was classified as not popular.
We found that @rockerjs/dao 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.