
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@chanson/node-server
Advanced tools
(windows 下无需 sudo 这 4 个字母)
sudo npm i
npm run new
npm run dev
熟悉 Util.js 里的函数,有需求时优先使用里面的函数,而不是另外写一个
获取前端 get 和 post 方法传递过来的参数
ctx.request.all()
session 的操作
ctx.session.get('user')
ctx.session.put('user', {name:'xxx'})
redis 的操作
await Redis.get(key)//返回字符串
await Redis.set(key, JSON.stringify(data))//对象要先转成字符串
await Redis.expire(key, 40000)//有效期
每个函数正常结束时调用。用途:规范函数的返回值,使得返回值具有相同的数据结构
Util.end({})
每个函数内部抛出异常时,在 catch 里调用本函数,使得返回值具有相同的数据结构
Util.error({})
Controller 里的函数正常结束时调用。规范要返回给前端的数据结构
Util.end2front({})
Controller 里的函数内部抛出异常时,在 catch 里调用本函数,规范要返回给前端的数据结构
Util.error2front({})
对返回前端的 id(数字型) 进行加解密,用于某些不希望前端直接看到内容的场景,比如 user_id
Util.encode(int)
Util.decode(str)
打印信息到控制台
log.debug('调试时建议用这个')
log.info('普通信息')
log.error('错误信息')
(根目录/.vscode/nodejs.code-snippets)请熟悉这个文件里的。自定义了一些代码片段,比如输入 func,vscode 就会智能提示 funcController... 按下 tab 键,就会把 controller 下的函数结构补全
FAQs
Node.js MVC Framework
The npm package @chanson/node-server receives a total of 15 weekly downloads. As such, @chanson/node-server popularity was classified as not popular.
We found that @chanson/node-server 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
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

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.