Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
anyroute-server
Advanced tools
A server to enable you to define the request and response quickly, you can set the request path and the response in the way you like with just lines of code, including mock, inverse-proxy and so on.
A server to enable you to define the request and response quickly, you can set the request path and the response in the way you like with just lines of code, including mock, inverse-proxy and so on.
The server also offer a basic funcionality to work as a basic static server.
npm install -g anyroute-server
You can start the server without any parameters if you just want to set current directory as a static server:
anyroute-server
And it also support some params below:
-p
port of the server, default to 3000-d
directory of the server, default to current path-c
path of the route config file, default to a route.config.js
of current path if existsmodule.exports = {
// mock response
'remote/demo.json': function (req, res) {
setTimeout(() => {
res.json({
stat: 'ok',
data: []
})
}, 300);
},
// map local, replace the remote file.js with local file
'remote/file.js': 'fullpath/of/local/file.js',
// example.com/remote/path => http://localhost/local/path
'example.com/remote/path': 'http://localhost/local/path',
// example.com/remote/original-path => http://another.com/remote2/original-path
'/remote/(.*)': 'http://another.com/remote2'
}
Mock response for specified urls, you can simulate a network delay with setTimeout
. In the related resposne function, this module exports some meta data and method for your convenience.
/*
the function to do the mock thing
@param req the request data
{req.url} full url of the request
{req.protocol}
{req.headers} the headers of the request
{req.body} the buffer body of the ruequest
@param res a util to do response, it contains some handy functions
{req.json(object)} response a json object
{req.set(object|{key, value})} set reponse headers
{req.type(json|html|text|png)} set the mime types
{req.status(statusCode)} set status code
{req.jsonp(json[, callbacQueryName])} return a jsonp
{req.end(string|object)} response the data
*/
function (req, res) {
}
Map the remote file path with local file, useful when want to proxy a remote file
'remote/file.js': 'fullpath/of/local/file.js'
Map remote request to another target
//
'example.com/remote/path': 'http://localhost/local/path'
It also support to keep part of original path to target server '/remote/(.*)': 'http://another.com/remote2'
FAQs
A server to enable you to define the request and response quickly, you can set the request path and the response in the way you like with just lines of code, including mock, inverse-proxy and so on.
We found that anyroute-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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.