Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
node-http-server
Advanced tools
A very simple and fast http server for node, bash, and spawnable from C, Python etc. It is lightweight and great for embedded solutions as well as everyday development or public facing apps.
Simple to use stand alone node HTTP Server you can spin up from node apps, bash scripts, the commandline, C or python apps etc.
npm install node-http-server
port : 8080
root : Current Working Directory (where you execute the command from)
domain : localhost
index : index.html
verbose : false
noCache : true
port
the port on which the server should run
root
the absolute location to the root dir for the public file system
domain
the domain which this server applies to - this is not yet implemented
index
the default file to look for in a dir. if not found a 404 will be displayed
verbose
should the server display detailed info about what it is doing
noCache
should the server prevent caching
contentType : {
html : 'text/html',
css : 'text/css',
js : 'text/javascript',
json : 'application/json',
txt : 'text/plain',
jpeg : 'image/jpeg',
jpg : 'image/jpeg',
png : 'image/png',
gif : 'image/gif',
ico : 'image/x-icon',
appcache: 'text/cache-manifest'
}
restrictedType: {}
errors : {
headers : {
'Content-Type' : 'text/plain'
},
404: '404 MIA',
415: '415 File type not supported',
403: '403 Access Denied',
500: '500 {{err}}'
}
contentType
mapping of file extension to header content type
restrictedType
extensions to which external access will be denied
errors
error headers and error strings, these can be anything you like from html to text etc. just make sure they all can use the same headers. The 500 error will replace {{err}}
in the specified value with the actual error message from the server.
launch
is an argument that specifies to launch the server now with the provided arguments and defaults
node ~/git/node-http-server/server/http.js root=~/myApp/ port=9999 launch=now
you can specify any of the variables frpom the currently modifiable via any interface, commandline, bash, node etc. section above. The order does not matter.
node ~/git/node-http-server/server/http.js root=~/myApp/ port=8888 verbose=true launch=now
var server=require('../server/http.js');
server
has 2 methods, deploy
and configTemplate
server.configTemplate
will generate a complete config file based off of the default values and arguments passed in when launching the app. DO NOT USE launch=now as an argument for a node app. This will result in launching 2 servers, the one you specify with the arguments passed and then the one the node app launches too.
server.deploy
will accept any config params and merge them with a fresh configTemplate, so passing a modified config based off of server.configTemplate()
will result in using only the values from the modified config passed when deploying as it will override all of the defaults. The passed config object only merges to one level deep so if you pass a multi level object like contentTypes
it will overwrite the default config with what you sent for that object rather than merging your object with the default.
can be found in the examples folder
this app could be launched as
node basicApp.js verbose=true
to force verbose logging. This can be helpful if you have many servers in a single app and want them all to be verbose right now for debugging or testing purposes.
var server=require('../server/http.js');
console.log(server);
server.deploy(
{
port:8000,
root:'~/myApp/'
}
);
var server=require('../server/http.js');
console.log(server);
server.deploy(
{
verbose:true,
port:8001,
root:'~/myApp/'
}
);
var server=require('../server/http.js');
console.log(server);
var config=server.configTemplate();
config.errors['404'] = 'These are not the files you are looking for...';
config.contentType.mp4 = 'video/mp4';
config.port = 8005;
config.verbose = true;
config.root = '~/myApp/'
server.deploy(config);
It is helpful especially when running multiple servers to label them with --uid
for easy to remember process names
when starting the same server many times, like every time the system boots you will want to append to the same log file so use -a
. Without -a
forever will throw an error stating that the log file for the --uid
already exists.
forever --uid nodeServer -a start ~/git/node-http-server/server/http.js root=~/myApp/ port=9999 launch=now
This can be set as a .profile
command or a .bash_rc
command as well if you want to launch the server every time the computer boots up.
FAQs
A very simple and fast http server for node, bash, and spawnable from C, Python etc. It is lightweight and great for embedded solutions as well as everyday development or public facing apps.
The npm package node-http-server receives a total of 1,691 weekly downloads. As such, node-http-server popularity was classified as popular.
We found that node-http-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.