
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
bedrock-server
Advanced tools
A bedrock module that provides a basic HTTP and HTTPS server. Other modules, such as bedrock-express, typically provide a routing framework and other features for writing Web applications, but depend on this module for core low-level functionality like listening for incoming connections, redirecting HTTP traffic to the HTTPS port, and configuring SSL/TLS.
npm install bedrock-server
An example of attaching a custom request handler to the server once Bedrock is ready.
var bedrock = require('bedrock');
var server = require('bedrock-server');
// once bedrock is ready, attach request handler
bedrock.events.on('bedrock.ready', function() {
// attach to TLS server
server.servers.https.on('request', function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
});
bedrock.start();
By default, bedrock-server
will redirect any HTTP requests to HTTPS. To
replace this default behavior, do the following:
var server = require('bedrock-server');
// once bedrock is ready, attach request handler
bedrock.events.on('bedrock.ready', function() {
// attach to HTTP server
server.servers.http.on('request', function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
});
bedrock.start();
For documentation on server configuration, see config.js.
bedrock.localhost
hostname (or whatever you've configured) to your
machine:
bedrock.localhost
.
For example: 127.0.0.1 localhost bedrock.localhost
.
(If accessing the server externally, you may need to use the IP address
of your primary network device).To access the server once bedrock is running:
List of emitted Bedrock Events:
{address, port}
: Object with address and port to listen on.{address, port}
: Object with address and port now listening on.{address, port}
: Object with address and port to listen on.{address, port}
: Object with address and port now listening on.TODO
FAQs
Bedrock core server module
We found that bedrock-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.