
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
webpack-dev-mock
Advanced tools
mock-dev-server 是一个 express 服务的中间件
读取项目目录下的 mock/index.js
文件生成,会配置对应的接口。
// mock/index.js
const foo = require('./foo.json');
const bar = require('./bar');
module.exports = {
// 同时支持 GET 和 POST
'/api/users/1': foo,
'/api/foo/bar': bar(),
// 支持标准 HTTP
'GET /api/users': { users: [1, 2] },
'DELETE /api/users': { users: [1, 2] },
// 支持自定义函数,API 参考 express4
'POST /api/users/create': (req, res) => {
res.end('OK');
},
// 支持参数
'POST /api/users/:id': (req, res) => {
const { id } = req.params;
res.send({ id: id });
},
};
// server.js
const express = require('express');
const mockServer = require('mock-server');
const app = express();
mockServer(app);
app.get('/', (req, res) => res.send('hello world'));
app.listen(6001, () => {
console.log('Example app listening on port 6001!');
console.log('http://127.0.0.1:6001');
});
FAQs
Webpack devserver middleware mock server
The npm package webpack-dev-mock receives a total of 262 weekly downloads. As such, webpack-dev-mock popularity was classified as not popular.
We found that webpack-dev-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.