Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
egg-generator
Advanced tools
基于eggjs框架搭建的代码生成器, 目前支持CRUD生成, 生成内容包括
服务端代码: eggjs restful 代码骨架文件
app/controller/api/v1/{name}.js
app/model/{name}.js
app/service/{name}.js
app/router.js
// 路由注册代码
后台管理代码: ant design pro (page list, model form, update, delete) 挂历界面
eggjs
+ egg-sequelize
+ ant design pro
中后台项目并用egg-generator
快速生成代码注意: 数据层目前只支持生成基于Sequelize的代码, 不支持
typescript
代码生成
egg.js
)$ npm i egg-init -g // 安装eggjs官方生成器
$ egg-init project --type=simple // 生成项目
$ cd project // 进入项目目录
$ npm i // 安装依赖
ant design pro
)注意: 后台目录名必须为
backend
, 且必须在项目根目录下. 例如:project/backend
$ npm i ant-design-pro-cli -g // 安装ant design pro官方生成器
$ pro new // 生成后台, project name输入为: `backend`
注意:以上两部为项目初始搭建, 如果已有的项目中集成可以跳过以上两步. 独立后台项目可以软连接为
backend
既可. 前提必须按照eggjs
和ant design pro
标准目录结构.
$ cd .. // 进入项目根目录
$ npm i egg-isequelize egg-async-ivalidator // 引入数据库操作类和数据验证类
$ npm i mysql2 // 如果是msyql数据库需引入mysql2, 其他数据库请查看Sequelize文档
// 编辑 plugin.js, 加入以下代码
exports.sequelize = {
enable: true,
package: 'egg-isequelize'
}
exports.validate = {
enable: true,
package: 'egg-async-ivalidator',
};
exports.generator = {
enable: true,
package: 'egg-generator',
};
// 编辑config.default.js 加入数据库操作源
exports.sequelize = {
// single database
client: {
dialect: 'mysql',// support: mysql, mariadb, postgres, mssql
database: 'test',
host: 'localhost',
port: '3306',
username: 'root',
password: '',
hooks: {
afterDefine(Model) {
// add paginate method
require('sequelize-pagination')({
oneBaseIndex: true,
pageSize: 20,
})(Model);
},
},
},
};
$ cd project && npm run dev // 项目根目录启动服务
$ cd backend && npm start // 启动管理后台
FAQs
the CRUD generator plugin for egg
The npm package egg-generator receives a total of 1 weekly downloads. As such, egg-generator popularity was classified as not popular.
We found that egg-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.