
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-fashion
Advanced tools
npm install --save node-fashion
/api12321falseconsole{
url: '/users',
method: 'GET',
description: '获取用户列表',
handle: function (req, res) {
...
res.respond(null, [
{id: 1, name: 'qwe'},
{id: 2, name: 'aaa'},
])
}
}
server.interceptors(function (req, res, route, next) {
console.log(route)
next()
})
nulldone()方法来结束该回调函数 // 调用通用响应处理函数
function (req, res) {
// ...
// error - errorCode默认是`500`
res.respond(new Error('error message'))
res.respond(new Error('error message'), 401)
res.respond('error message', 401)
// success
res.respond(null, [{id: 1, name: 'qwe'}, {id: 2, name: 'aaa'}])
}
users.js
module.exports = [
{
url: '/users',
method: 'get',
handle: function (req, res) {
res.respond(null, [
{
id: 123,
name: 'sdx'
},
{
id: 234,
name: 'dss'
}
])
}
},
{
url: '/users/:id',
method: 'get',
handle: function (req, res) {
res.respond(null, 'get users by id.')
}
},
{
url: '/users',
method: 'post',
handle: function (req, res) {
res.respond(null, 'add a user.')
}
}
]
api.js
module.exports = [
require('./users'),
{
url: '/hello-world',
method: 'get',
handle: function (req, res) {
res.send('hello world.')
}
}
]
index.js
var Server = require('node-fashion')
var server = new Server()
// add middleware
server.use(function (req, res, next) {
console.log('============[配置中间件]=============')
next()
})
// add basic api
server.use('/hello', function (req, res) {
console.log('create api by [/hello].')
res.send('test success.')
})
// 统一接口函数处理
server.handle(require('./api'))
server.start()
FAQs
a node http server framework.
The npm package node-fashion receives a total of 20 weekly downloads. As such, node-fashion popularity was classified as not popular.
We found that node-fashion 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.

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.