
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
```exmd```的核心代码, 包含的功能有: 1. ```startProject``` 启动项目 2. ```BaseModel``` model基类 3. ```migrate``` 数据库表转model 4. ```asyncdb``` model转数据库表 5. ```renderRequestType``` controller方法的请求配置 - 配置请求 - 配置swagger及swagger中的参数和返回参数描述 6. ```handleClientAdapter``` 持久层
exmd的核心代码, 包含的功能有:
startProject 启动项目BaseModel model基类migrate 数据库表转modelasyncdb model转数据库表renderRequestType controller方法的请求配置handleClientAdapter 持久层适配器,它能指定数据源,对数据源中的表对应的model操作ResultVo 返回的结果集合AuthController 内置的登录注册controllerUploadController 内置的文件上传控制器数据源配置 目前只支持postgresql数据库,后续将会扩展
module.exports = {
// 数据库1
postgresql1: {
type: 'postgresql',
data: {
user: 'bserverx',
database: 'bserver',
password: 'bserverx123',
host: 'localhost',
port: '5432',
poolSize: 5,
poolIdleTimeout: 30000,
reapIntervalMillis: 10000
}
}
}
启动项目
startProject({
/**
* 是否开启调试模式
* 调试模式将会打印sql
* 调试模式下不会发送邮件
*/
isDebugger: true,
/**
* api地址路由配置
*/
router,
/**
* 数据源
*/
Datasource,
/**
* 用户model
*/
authUserModel: UserModel,
/**
* 登录注册使用的数据源对应key
*/
authDataSourceKey: 'postgresql1',
/**
* 注册邮箱使用的内容模板
* 没有配置将会使用默认模板
* @param {*} code
* @returns
*/
authEmailContent: (code) => {
return `
<p>您好:</p>
<p>您的验证码是:<strong style="color:orangered;">${code}</strong></p>
<p>嘿嘿</p>
`
},
/**
* 登录注册验证码超时时间
*/
authEmailCodeMaxTime: '1minute',
// 一个邮箱最多允许绑定多少个用户
authEmailBindUserMax: 3,
// token生成私钥
authPrivateKey: 'abc123',
// hour/minute/second
authTokenTime: '1minute',
/**
* 发邮件库,
* 目前只支持 tencenmail
*/
emailLib: 'tencenmail',
/**
* 邮箱配置
*/
emailConfig,
/**
* 返回数据的结果集合模板
*/
ResultVo,
// swagger的路径配置
swaggerUrl: '/swagger/data',
// 文件上传的保存路径
uploadBaseUrl: '/Users/wujianfei/test-upload-files',
/**
* 文件上传模块划分, 必须传
* 上传的文件路径:基础路径下 文件名称: [模块名称_时间戳],
* 比如default下的文件名称:
* test1_1657007903331.mp4
*/
uploadFileDirectorys: [{
name: 'test1'
}, {
name: 'default'
}],
// 文件限制配置
uploadLimits: {
fileSize: 10 * 1024 * 1024 * 1024
}
})
文件上传和登录模块使用 可参考提供的后端模板项目中的路由,看注释即可
const { AuthController, UploadController } = require('exmd')
const router = [
{
url: '/bserve/',
controller: UploadController
},
{
url: '/bserve/',
controller: AuthController
}
...自己定义的controller
]
ResultVo 可以根据该ResultVo自定义
/**
* 返回实体类
* @param {*} params
*/
function ResultVo(params) {
const { status, data, message } = params
if (status === undefined) {
throw new Error('status is undefined')
}
if (data === undefined && message === undefined) {
throw new Error('both and data are undefined')
}
return {
status,
data,
message
}
}
ResultVo.prototype.swaggerDescription = {
status: '状态 0正常',
data: '',
message: '异常信息'
}
module.exports = ResultVo
UserModel 可以根据该model自定义模板放到models目录下
const { BaseModel } = require('exmd')
const fieldsMap = {
id: {
type: 'uuid',
length: 16,
lengthvar: -1,
notnull: true,
comment: null,
isPrimary: true,
pk_name: 'omuser_pkey'
},
username: {
type: 'text',
length: -1,
lengthvar: -1,
notnull: true,
comment: null
},
password: {
type: 'text',
length: -1,
lengthvar: -1,
notnull: true,
comment: null
},
email: {
type: 'text',
length: -1,
lengthvar: -1,
notnull: true,
comment: null
},
fullName: {
type: 'text',
length: -1,
lengthvar: -1,
notnull: true,
comment: null
},
isactive: {
type: 'int4',
length: 4,
lengthvar: -1,
notnull: true,
comment: null
},
realname: {
type: 'text',
length: -1,
lengthvar: -1,
notnull: false,
comment: null
}
}
function omuser() {
const vm = this
BaseModel.apply(vm, arguments)
vm.fields = fieldsMap
vm.tableName = 'omuser'
}
;(function () {
const TempFun = function () {}
TempFun.prototype = BaseModel.prototype
omuser.prototype = new TempFun()
})()
module.exports = omuser
构建
npm run build
提交所有代码
npm run push:all
发布
npm run publish:exmd
npm run publish:aux
源码仓库已提交申请中,请耐心等待
FAQs
```exmd```的核心代码, 包含的功能有: 1. ```startProject``` 启动项目 2. ```BaseModel``` model基类 3. ```migrate``` 数据库表转model 4. ```asyncdb``` model转数据库表 5. ```renderRequestType``` controller方法的请求配置 - 配置请求 - 配置swagger及swagger中的参数和返回参数描述 6. ```handleClientAdapter``` 持久层
We found that exmd 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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.